Codefixer - ASP tutorials, resources and software
asp.netPRO “Best ASP.NET Host” – DiscountASP.NET
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Tuesday 13 May
MembersPro PayPal - ASP Membership software

ASP.NET 3.5 Hosting – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

Date, Time, Hour, Now functions

These are handy VBScript functions that allow us to easily access date and times. They return a value taken from the computer's system clock.

The Date function

<%
Dim theDate 'create variable that will store the date
theDate=Date 'the Date function returns the date and we assign it to the variable
Response.write theDate 'write out the date
%>

The date is: 13/05/2008

The Time function

<%
Dim theTime 'create variable that will store the time
theTime=Time'the Time function returns the date and we assign it to the variable
Response.write theTime 'write out the time
%>

The time here in Ireland is: 14:23:32

The Now function

<%
Dim varNow 'create variable that will store date and time
varNow=Now 'the Now function returns the date & time - assign it to the variable
Response.write varNow 'write out the date and time
%>

The date and time is: 13/05/2008 14:23:32

Notice that all the functions above haven't any parameters passed in unlike the Hour function below.

The Hour function

The Hour function returns a number between 0 and 23 that represents the hour of the day.

<%
Dim theHour 'create variable that will store the hour
theHour=Hour(Now)'we pass in the Now function as a parameter
Response.write theHour 'write out the hour
%>

The hour here is: 14

Other date and time related tutorials:

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
Display the dates and times
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