Time Formatting

Drew -1 Tallied Votes 311 Views Share

Learn how to take the Now() command and format it in a bunch of differnt ways.

Code from: http://www.iportalx.net

<%= Date() %>
Produces: 07/01/2002

<%= Now() %>
Produces: 07/01/2002 3:47:42 PM

<%= Time() %>
Produces: 3:47:42 PM

<%= FormatDateTime(strDate, 0) %>
Produces: 07/01/2002 3:47:42 PM

<%= FormatDateTime(strDate, 1) %>
Produces: Monday, July 01, 2002

<%= FormatDateTime(strDate, 2) %>
Produces: 07/01/2002

<%= FormatDateTime(strDate, 3) %>
Produces: 3:47:42 PM

<%= FormatDateTime(strDate, 4) %>
Produces: 15:47

<%= Year(strDate) %>
Produces: 2002

<%= Month(strDate) %>
Produces: 7

<%= MonthName(Month(strDate)) %>
Produces: July

<%= MonthName(Month(strDate), 1) %>
Produces: Jul

<%= Day(strDate) %>
Produces: 1

<%= WeekDay(strDate) %>
Produces: 2

<%= WeekDayName(WeekDay(strDate)) %>
Produces: Monday

<%= WeekDayName(WeekDay(strDate), 1) %>
Produces: Mon

<%= Minute(strDate) %>
Produces: 47

<%= Second(strDate) %>
Produces: 42

<%= DateAdd("d", 1, strDate) %>
Produces: 07/02/2002 3:47:42 PM

<%= DateAdd("d", -1, strDate) %>
Produces: 06/30/2002 3:47:42 PM

<%= DateDiff("d", "1/1/2000", strDate) %>
Produces: 912

<%= Day(strDate) & "/" & Month(strDate) & "/" & Year(strDate) %>
Produces: 1/7/2002

<%= WeekDayName(WeekDay(strDate)) & ", " & Day(strDate) & " " & MonthName(Month(strDate)) & ", " & Year(strDate) %>
Produces: Monday, 1 July, 2002