VBScript FormatDateTime
Function
The FormatDateTime function formats and returns a valid date or time expression.
Syntax
Parameter | Description |
---|---|
date | Required. Any valid date expression (such as Date() or Now()). |
format | Optional. Specifies the format value for the date/time format. Possible values are: 0 = vbGeneralDate - Default. Returns date: mm/dd/yy and if time is specified: hh:mm:ss PM/AM. <br> 1 = vbLongDate - Returns date: weekday, monthname, year <br> 2 = vbShortDate - Returns date: mm/dd/yy <br> 3 = vbLongTime - Returns time: hh:mm:ss PM/AM <br> 4 = vbShortTime - Returns time: hh:mm |
Example
Example
Displaying the date in different formats:
The output of the above example: