PRB: VBScript Date and Time Formats Change with Logged on User
Retired KB Content Disclaimer
For example, an application may require that you display the year ina four-digit format instead of a two-digit format (for example, 1999versus 99). The user logs on to the Microsoft Internet Information Server (IIS) server and sets the Date formatunder Regional Settings in the Control Panel to use four-digityears (for example, mm/dd/yyyy). When the user opens the Active ServerPages (ASP) page in a browser, the year is displayed as four digits. When the user logs off the computer and opens the ASP page in a browser, theyear is displayed as two digits.
- Use JScript, which does not rely on the regional settings forits date and time formats.
- Use functions other than Now, Date, and Time to display dates and times. Because the other date and time functions (for example, Day, Month, and Year) do not rely on regional settings, the formats do not change when different users log on to the computer. For example, the MyDate function always returns the date in mm/dd/yyyy format:
Function MyDate() dteCurrent = Date() dteDay = Day(dteCurrent) dteMonth = Month(dteCurrent) dteYear = Year(dteCurrent) MyDate = dteMonth & "/" & dteDay & "/" & dteYear End Function
Article ID: 218964 - Last Review: 08/08/2007 06:46:45 - Revision: 2.1
- kbprb kbscript KB218964