Toxiclab.org

Date and Time

3.1.2006, 17:37
Submited in: Asp | Total Views: 23207

Remember: all of the examples of showing date and time in this tutorial show the time of a server.

That means, that, if your server is in the UK you’ll have the time that is on that server, in this case UK time.

Date

To show just date we use:

<% = date %>, which gives for instance: 15.12.2005

Time

To show just time we use:

<% = time %>, which gives for instance: 10:23:15

Now (date and time)

By using now we can show both date and time:

<% = now %>, which gives for instance: 13.12.2005 10:25:07

Ways of showing date and time

It is possible to show date and time in many ways, but we have choosen just some of the best.

Day

<% = day(now) %>

Month

<% = month(now) %>

Year

<% = year(now) %>

Names of days and months

To show which day in a week it is by number (1-7) we use:

<% = weekday(now) %>

To show a name of a day in a week we use:

<% = weekdayname(weekday(now)) %>

To show which month in a year it is by numbers we use:

<% = month(now) %>

To show a name of a month in a year we use:

<% = monthname(month(now)) %>

Hours, minutes and seconds

For hours we use:

<% = hour(now) %>

For minutes we use:

<% = minute(now) %>

For seconds we use:

<% =second(now) %>

Example:

<% response.write hour(now) & ":" & minute(now) & ":" & second(now) %>
will give: 10:39:25

Are you a website owner?
Click here to register and submit your tutorials!

Browse by category


Most popular tutorials