Home | Quizes | Downloads | Tech Terms | Tutorials | News | Forum | Site Map | Feedback

ASP Code Samples

Date/Time:

There are a few ways to specify time and date on your page. The following codes show you some choices to make.

Simple Date and Time calls.

To get a date with time, you can use <% Now () %>
This gives 6/3/2023 3:22:58 PM

You can retrive date only by using <% =Date() %>
This command returns only date 6/3/2023 on the server's side.
In the same way, guess what <% =Time () %> will return on server side.
If you thought 3:22:58 PM xx:xx:xx AM/PM, then you are right.

Using variables to pass date.

<% dim mydate
mydate = Date()
Response.write ""& mydate & ""
%>
This variable returns 6/3/2023  which is the same as using the now().

The same principle can be used to return time.


Formating your time.
You can use the following formatting structures on your page.

<% =FormatDateTime(Date, X) %>, X being numbers 1 and 2
1 being todays date and time in alphabets.[ Saturday, June 3, 2023
2 being [ 6/3/2023 ] as regular date.


I hope you found this interesting enough. If you have any suggestions, please post it to the Tech Forum or send us your Feedback



  
2004© Emefa Amenuvor [i][m][f][t][e][c][h] all rights reserved