| Answer: |
Use the FormatDateTime function. FormatDateTime takes two input paraemeters, a required date variable and an optional date format. There are five different date formats available:
vbGeneralDate - displays a date as a short date and a time as a long time.
vbLongDate - displays a date in the long format
vbShortDate - displays a date in the short format
vbLongTime - displays a time using the long format
vbShortTime - displays a time using the 24-hour format
The long and short formats are specified by the regional settings on the Web server. An example of using the FormatDateTime function can be seen below:
Dim dtNow dtNow = Now()
Response.Write FormatDateTime(dtNow, vbGeneralDate) & "<BR>" Response.Write FormatDateTime(dtNow, vbLongDate) & "<BR>" Response.Write FormatDateTime(dtNow, vbShortDate) & "<BR>" Response.Write FormatDateTime(dtNow, vbLongTime) & "<BR>" Response.Write FormatDateTime(dtNow, vbShortTime) & "<BR>"
|
The output of the above script is:
9/24/00 3:23:48 PM Sunday, September 24, 2000 9/24/00 3:23:48 PM 15:23
For more information be sure to read the technical docs! Also be sure to check out this FAQ: How can I display dates in a completely custom format (that might not be supported by FormatDateTime)? |