VBScript Date

To display the date using VBScript, you use the VBScript date() function.

VBScript Date Code

To display this to the user, you need to output it like you would anything else - for example, using the document.write() method.

Or even better, you could put the date into a variable first, then output the variable:

Both these result in the following.

Note: If this is blank, your browser probably doesn't support VBScript. Try using Internet Explorer.

VBScript Date Format

You can use the VBScript FormatDateTime() method to format the date to either a long date format or a short date format.

The FormatDateTime() method accepts two arguments: The date being formatted, and the required format (indicated by a constant). The formats are specified as follows:

Long Format

To use long date format, you pass the FormatDateTime() an argument of 1.

Short Format

To use long date format, you pass the FormatDateTime() an argument of 2.