Codefixer - ASP tutorials, resources and software
ASP.NET Hosting with US & UK Data Centers!
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Sunday 7 September
MembersPro PayPal - ASP Membership software

New MS SQL 2008 Available – 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 07/09/2008 06:56:40

<%= Date() %> prints out 07/09/2008

<%= Now() %> prints out 07/09/2008 06:56:40

<%= Time() %> prints out 06:56:40

<%= FormatDateTime(strNow, vbGeneralDate) %> prints out 07/09/2008

<%= FormatDateTime(strNow, vbLongDate) %> prints out 07 September 2008

<%= FormatDateTime(strNow,vbShortDate) %> prints out 07/09/2008

<%= FormatDateTime(strNow, vbLongTime) %> prints out 06:56:40

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

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

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

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

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

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

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

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

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

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

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