Codefixer - ASP tutorials, resources and software
ASP.NET 3.5 Hosting – Click Here!
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Saturday 10 May
MembersPro PayPal - ASP Membership software

ASP.NET 3.5 Hosting – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

Displaying and formatting Dates and Times

Just to clear up an issue, the date and time displayed on this page are provided by my server so may not be the same where you are. Some of the dates are displayed in UK format ie dd/mm/yyyy rather than the American mm/dd/yyyy, though they'll display correctly according to where your server is located.

<% strNow=Now()' this variable will be used later below %>

strNow holds the value 10/05/2008 03:03:02

<%= Date() %> prints out 10/05/2008

<%= Now() %> prints out 10/05/2008 03:03:02

<%= Time() %> prints out 03:03:02

<%= FormatDateTime(strNow, vbGeneralDate) %> prints out 10/05/2008

<%= FormatDateTime(strNow, vbLongDate) %> prints out 10 May 2008

<%= FormatDateTime(strNow,vbShortDate) %> prints out 10/05/2008

<%= FormatDateTime(strNow, vbLongTime) %> prints out 03:03:02

<%= FormatDateTime(strNow, vbShortTime) %> prints out 03:03

<%= Year(strNow) %> prints out 2008

<%= Month(strNow) %> prints out 5

<%=Day(strNow) %> prints out 10

<%=Hour(strNow) %> prints out 3

<%=Minute(strNow) %> prints out 3

<%=Second(strNow) %> prints out 2

<%= WeekDay(strNow) %> prints out 7

<%= WeekDayName(WeekDay(strNow)) %> prints out Saturday

<%= WeekDayName(WeekDay(strNow), 1) %> prints out Sat

Other date and time related tutorials:
Read more on the Date, Time and Now VBScript functions
Here's a code snippet to display the day and date (eg. Mon 25 December).
Here's a code snippet to display the day and date with the ordinal suffix (eg. Mon 25th December).
How to get the current month name
Time and Date based greetings
IsDate Function
The DateDiff DateAdd and DatePart Functions

LinksPro - Directory  and Link  Management Software




ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software