|
Date and Time by Iain Hendry
Knowing how to use the various date and time
functions is very important for all ASP programmers , in this
tutorial we will show you the basic date and time functions.
If you want to get the current date you can use
the Date function .
<%
Response.Write "The date is " & Date
%>
which will give us the following
<%
Response.Write "The date is " & Date
%>
We can also display the current date and time
using the Now function .
<%
Response.Write "The current date/time is " & Now
%>
which will display the following
<%
Response.Write "The current date/time is " & Now
%>
We can display the year , month and day by using
the functions Year , Month and Day .
<%
Response.Write "The year is " & Year(Date) &
"<br>"
Response.Write "The month is " & Month(Date) &
"<br>"
Response.Write "The day is " & Day(Date) &
"<br>"
%>
which will display the following
<%
Dim theDate
theDate = Date
Response.Write "The year is " & Year(Date) & " "
Response.Write "The month is " & Month(Date)& " "
Response.Write "The day is " & Day(Date)& " "
%>
We can also get the hours , minutes and seconds
by using the Hour , Minute and Second functions
<%
Response.Write "The hour is " & Hour(Now) &
"<br>"
Response.Write "The minutes are " & Minute(Now)
& "<br>"
Response.Write "The seconds are " & Second(Now)
& "<br>"
%>
which displays the following
<%
Response.Write "The hour is " & Hour(Now) & " "
Response.Write "The minutes are " & Minute(Now) & " "
Response.Write "The seconds are " & Second(Now) & " "
%>
|