Date()
To display the current date |
<% =date %> |
Output: |
Thu, Jan 26, 2009 |
Time()
To display the current time |
<% =time %> |
Output: |
11:19:46 PM |
Now()
To display the current date and time |
<% =now %> |
Output |
1/26/09 11:19:46 PM |
Month and Monthname |
To display the number of the current month . |
<% =month(now) %> |
You'll see a 1 if the current month is January, 2 if it's February, and so on. |
To display the name of the current month, type:
<% =monthname(month(now)) %> |
Day
To display the day of the current month |
<% =day(now) %> |
Year
To display the current year |
<% =year(now) %> |
Weekday and Weekdayname
To display the day of the week as a number from 1 to 7 . |
<% =weekday(now) %> |
Output is 1 if today is Sunday, 2 if it's Monday |
To display the day of the week by name, type:
|
<% =weekdayname(weekday(now)) %> |
Hour, Minute, and Second
To display just the hour part of the current time. |
<% =hour(now) %> |
The hour function is based on a 24-hour clock. When you see this number between 0 and 23. |
To display just the minutes part of the current time |
<% =minute(now) %> |
The output is number between 0 and 59. |
Another Way to Display the Time |
we'll need to write a script that looks at the hour and does one of the following:
- If the hour is 0 (zero), the script displays "midnight."
- If the hour is 12, the script displays "noon."
- If the hour is between 1 and 11, the script doesn't change it, but it displays "AM" after "o'clock."
- If the hour is between 13 and 23, the script subtracts 12 (to make it a number between 1 and 11) and displays "PM" after "o'clock."
. The hour is
|
<% if hour(now) = 0 then %>
midnight.
<% end if
if hour(now) = 12 then %>
noon.
<% end if
if (hour(now) >= 1) and (hour(now) <= 11) then %>
<% =hour(now) %> o'clock AM.
<% end if
if (hour(now) >= 13) and (hour(now) <= 23) then %>
<% =hour(now) - 12 %> o'clock PM.
<% end if %> |
|