FormatDateTime Function

Tips >>ASP Functions

WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE

The FormatDateTime function formats and returns a valid date or time expression. This function was created to compensate for the poor date and time formatting capabilities available to the ASP (VBScript) developer. FormatDateTime () just doesn't cut it! This function analysis to the Format() function in the Visual Basic world.

The Syntax of the FormatDateTime function is :-

FormatDateTime (date,format)

Its Description is :-

Format Values

Constant Value Description
vbGeneralDate 0 Display a date in format mm/dd/yy. If the date parameter is Now(), it will also return the time, after the date.
vbLongDate 1 Display a date using the long date format: weekday, month day, year.
vbShortDate 2 Display a date using the short date format: like the default (mm/dd/yy).
vbLongTime 3 Display a time using the time format: hh:mm:ss PM/AM.
vbShortTime 4 Display a time using the 24-hour format: hh:mm.

Example#1 :-

Using VB General Date Format

Code :-
document.write("The current date is: ")
document.write(FormatDateTime(Date()))
Output :-

The current date is: 2/22/2001

Example#2 :-

Using VB Long Date Format

Code :-
document.write("The current date is: ")
document.write(FormatDateTime(Date(),1))
Output :-

The current date is: Thursday, February 22, 2001

Example#3 :-

Using VB Short Date Format

Code :-
document.write("The current date is: ")
document.write(FormatDateTime(Date(),2))
Output :-

The current date is: 2/22/2001

Example#4 :-

Using VB Long Time Format

Code :-
<% =FormatDateTime("6/26/43") %>
<% =FormatDateTime("15:34") %>
Output :-
3:34:00 PM

Example#5 :-

VB Short Time Format

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

15:34

 
E-mail : sales@virtualsplat.com
Phone : +91-9892413501

Whatsapp Icon +91-9967648641

Whatsapp Icon +91-9967648641