Friday, July 11, 2008

Displaying Date and time in VB Script with ASP Classic

To display the Date and Time in your ASP page with certain format is very simple indeed. Take a look at the examples as below:

  1. <%=time()%>
    - Get current time
    - e.g. 9:52:30 AM

  2. <%=date()%>
    - Get current date
    - e.g. 7/11/2008

  3. <%=now()%>
    - Get current date and time
    - e.g. 7/11/2008 9:54:03 AM

  4. <%=FormatDateTime(now,0)%>
    - e.g. 7/11/2008 9:55:41 AM

  5. <%=FormatDateTime(now,1)%>
    - e.g. Friday, July 11, 2008

  6. <%=FormatDateTime(now,2)%>
    - e.g. 7/11/2008

  7. <%=FormatDateTime(now,3)%>
    - e.g. 9:57:49 AM

  8. <%=FormatDateTime(now,4)%>
    - e.g. 09:58

  9. <%=WeekDay(now)%>
    - Day of the week
    - e.g. 6

  10. <%=WeekDayName(WeekDay(now))%>
    - e.g. Friday

  11. <%=Day(date)%>
    - Day of the month
    - e.g. 11

  12. <%=Month(date)%>
    - Month of the year
    - e.g. 7

  13. <%=MonthName(Month(date))%>
    - e.g. July

  14. <%=Year(date)%>
    - Current year
    - e.g. 2008

  15. <%=Right(Year(date),2)%>
    - Current year
    e.g. 08

  16. <%=Hour(now)%>
    - Hour part
    - e.g. 10

  17. <%=Minute(now)%>
    - Minute part
    - e.g. 11

  18. <%=Second(now)%>
    - Second part
    - e.g. 2

Hope you will find this helpful.

2 comments:

iiSwanSongii on August 15, 2008 at 8:58 PM said...

It looks like all of these would display the 'server' date and times correct?

Do you know any VBScript that will display the 'clients' date and time?

I have an email form that people will fill out that I need the date and time to be in the email submission but all that i've found only send through the server time.

thanks in advanced!

ejuly on August 18, 2008 at 4:35 PM said...

You can use a javascript, coz this runs in the client browser. Here are some of the examples that you can refer to:

1. Displaying the client's current date and time

2. Display client's PC Date & Time

 

Get paid for your opinions! Click on the banner above to join Planet Pulse. Its totally free to sign up, and you can earn UNLIMITED. Find out more by visiting PLANET PULSE.
July Code Blog Copyright © 2010 Blogger Template Designed by Bie Blogger Template