PRB: VBScript Date and Time Formats Change With Logged On User

ID: Q218964


The information in this article applies to:


SYMPTOMS

When you use the VBScript Now(), Date(), or Time() functions, the date and time formats differ depending on the user that is logged on to the computer. This creates a problem for server applications that are developed using Active Server Pages where the date or time formats are critical, but the date or time formats change when different users log on to the server or when no users are logged on.

For example, an application might require that you display the century in a four-digit format instead of a two-digit format (for example, 1999 versus 99). The user logs on to the IIS server and sets the Date format under Regional Settings in the Control Panel to use four-digit years (for example, mm/dd/yyyy). When the user opens the Active Server Page in a browser, the year is displayed as four digits. When the user logs off the computer and opens the Active Server Page in a browser, the year is displayed as two digits.


CAUSE

The VBScript functions Now(), Date(), and Time() rely on the Regional Settings in the computer for their formats. Regional Settings change, depending on the user logged on (or not logged on) to the computer. As a result, there is no way to guarantee that date and time formats will always be the same.


RESOLUTION

To ensure that your date and time formats are consistent, do one of the following:


STATUS

This behavior is by design.


REFERENCES

For more information on VBScript and JScript, visit the MSDN Scripting site at:

http://msdn.microsoft.com/scri pting

Additional query words:


Keywords          : kbASP kbScript kbVBScript300 kbGrpASP kbVBScript400 kbVBScript500 
Version           : WINDOWS:3.0,4.0,5.0; winnt:
Platform          : WINDOWS winnt 
Issue type        : kbprb 

Last Reviewed: April 28, 1999