ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾VBScript£¾VBScript


objects constants operators statements functions properties methods






FUNCTION:  FormatDateTime( )

FormatDateTime(Date, DateFormat)

The FormatDateTime function formats dates and times.


There is one mandatory arguments.

Date

The Date argument is any valid date expression.

Code:
<% =FormatDateTime("6/26/1943") %>
<% =FormatDateTime("15:34") %>

Output:
6/26/43
3:34:00 PM


There is one optional arguments.

DateFormat

The optional DateFormat argument must use the constant or value from the Date Format CONSTANTS.

CONSTANTVALUEDESCRIPTION
VBGENERALDate0Display the date and time using system settings
VBLONGDate1Display the date in long date format
June 26, 1943
VBSHOrTDate2Display the date in short date format
6/26/43
VBLONGTime3Display the time in long time format
3:48:01 PM
VBSHOrTTime4Display the time in short time format (24 hour clock)
15:48

Code:
<% =FormatDateTime("6/26/1943", 1) %>
<% =FormatDateTime("3:34:00 PM", 4) %>

Output:
Saturday, June 26, 1943
15:34