ASP Net Center.com
ASP Tutorials & Basics
Introduction
Variables & Arrays
Sub & Functions
If Statements
Case Statements
Loop Statements
Date Objects
Form Processing
Text File Objects
Database Access
Adding Record
Updating Record
Deleting Record
Virtual Includes
Cookies
E-mail
Server Variables
Creating Login Page

Displaying Date & Time with ASP

You use time() to get the current time, Date() to get the current date, and now() to get the current date & time.
For example, these examples will Illustrate use of date and time functions.
ExampleResult
<%=time()%> 5:58:53 AM
<%=date()%> 5/17/2008
<%=now()%> 5/17/2008 5:58:53 AM
<%response.write("Current date & time: "&now())%> Current date & time: 5/17/2008 5:58:53 AM
<%= FormatDateTime(Date, 0)%> 5/17/2008
<%= FormatDateTime(Date, 1)%> Saturday, May 17, 2008
<%= FormatDateTime(now, 3)%> 5:58:53 AM
<%= FormatDateTime(now, 4)%> 05:58
<%response.write("Day of the week: "&WeekDay(Date))%> Day of the week: 7
<%response.write("Day of the month: "&Day(Date))%> Day of the month: 17
<%response.write("Current Year: "&Year(Date))%> Current Year: 2008
<%response.write("Current Year: "&Right(Year(Date),2))%> Current Year: 08
<%response.write("Today is: "&WeekDayName(WeekDay(Date)))%> Today is: Saturday
<%response.write("Hour Part: "&(hour(now)))%> Hour part: 5
<%response.write("Minute Part: "&Minute(now()))%> Minute part: 58
<%response.write("Second Part: "&Second(now()))%> Second part: 53
Loops Database Access