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()%> 2:16:39 AM
<%=date()%> 3/10/2010
<%=now()%> 3/10/2010 2:16:39 AM
<%response.write("Current date & time: "&now())%> Current date & time: 3/10/2010 2:16:39 AM
<%= FormatDateTime(Date, 0)%> 3/10/2010
<%= FormatDateTime(Date, 1)%> Wednesday, March 10, 2010
<%= FormatDateTime(now, 3)%> 2:16:39 AM
<%= FormatDateTime(now, 4)%> 02:16
<%response.write("Day of the week: "&WeekDay(Date))%> Day of the week: 4
<%response.write("Day of the month: "&Day(Date))%> Day of the month: 10
<%response.write("Current Year: "&Year(Date))%> Current Year: 2010
<%response.write("Current Year: "&Right(Year(Date),2))%> Current Year: 10
<%response.write("Today is: "&WeekDayName(WeekDay(Date)))%> Today is: Wednesday
<%response.write("Hour Part: "&(hour(now)))%> Hour part: 2
<%response.write("Minute Part: "&Minute(now()))%> Minute part: 16
<%response.write("Second Part: "&Second(now()))%> Second part: 39
Loops Database Access