sas

Topic: ASP


Displaying the current date and Time

The date and time described in this section are those that are on the server.
Just to clear up an issue, the date and time displayed on this page are provided by my server so may not be the same where you are. Some of the dates are displayed in UK format ie dd/mm/yyyy rather than the American mm/dd/yyyy, though they'll display correctly according to where your server is located.
<% strNow=Now() ' this variable will be used later below %>

strNow holds the value 11/08/2006 21:18:09

<%= Date() %> prints out 11/08/2006

<%= Now() %> prints out 11/08/2006 21:18:09

<%= Time() %> prints out 21:18:09

<%= FormatDateTime(strNow, vbGeneralDate) %>
prints out 11/08/2006

<%= FormatDateTime(strNow, vbLongDate) %>
prints out 11 August 2006

<%= FormatDateTime(strNow,vbShortDate) %>
prints out 11/08/2006

<%= FormatDateTime(strNow, vbLongTime) %>
prints out 21:18:09

<%= FormatDateTime(strNow, vbShortTime) %>
prints out 21:18

<%= Year(strNow) %>
prints out 2006

<%= Month(strNow) %>
prints out 8

<%=Day(strNow) %>
prints out 11

<%=Hour(strNow) %>
prints out 21

<%=Minute(strNow) %>
prints out 18

<%=Second(strNow) %>
prints out 9

<%= WeekDay(strNow) %>
prints out 6

<%= WeekDayName(WeekDay(strNow)) %>
prints out Friday

<%= WeekDayName(WeekDay(strNow), 1) %>
prints out Fri
Prev