<% DateVar = Now() %> Date and Time on ASP pages - HouseOfScripts Resources

  Search HouseOfScripts.com

 

All Scripts        JavaScripts        ASP Scripts        Other Scripts

 

  Date and Time on ASP pages. asp, send, email, cdonts, link, recordset, hyper, hyperlink, create, list, box, dependant, dynamic

I found a few nice tips on how use time on ASP pages. I decided to summarize everything I found.

Everything begins with:
<% DateVar = Now() %>

<%= Date() %>

<%= Now() %>

<%= Time() %>

<%= FormatDateTime(DateVar, 0) %>

<%= FormatDateTime(DateVar, 1) %>

<%= FormatDateTime(DateVar, 2) %>

<%= FormatDateTime(DateVar, 3) %>

<%= FormatDateTime(DateVar, 4) %>

<%= Year(DateVar) %>

<%= Month(DateVar) %>

<%= MonthName(Month(DateVar)) %>

<%= MonthName(Month(DateVar), 1) %>

<%= Day(DateVar) %>

<%= Hour(DateVar) %>

<%= Minute(DateVar) %>

<%= WeekDay(DateVar) %>

<%= WeekDayName(WeekDay(DateVar)) %>

<%= WeekDayName(WeekDay(DateVar), 1) %>

<%= Minute(DateVar) %>

<%= Second(DateVar) %>

<%= DateAdd("m", 1, DateVar) %>

<%= DateAdd("m", -1, DateVar) %>

<%= DateAdd("d", 1, DateVar) %>

<%= DateAdd("d", -1, DateVar) %>

<%= DateAdd("h", 1, DateVar) %>

<%= DateAdd("h", -1, DateVar) %>

<%= DateDiff("m", "1/1/2000", DateVar) %>

<%= DateDiff("d", "1/1/2000", DateVar) %>

<%= DateDiff("h", "1/1/2000", DateVar) %>

<%= Day(DateVar) & "/" & Month(DateVar) & "/" & Year(DateVar) %>

<%= WeekDayName(WeekDay(DateVar)) & ", " & Day(DateVar) & " "
& MonthName(Month(DateVar)) & ", " & Year(DateVar) %>

 

Settings
The interval argument can have the following values:

Setting
Description
yyyy
Year
q
Quarter
m
Month
y
Day of year
d
Day
w
Weekday
ww
Week of year
h
Hour
n
Minute
s
Second

 

 


Home       Scripts       Active WebTools       Web Templates       Forum       Tools        Hosting       Questions/Comments       Add/Request