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()%> 10:51:52 PM
<%=date()%> 3/11/2010
<%=now()%> 3/11/2010 10:51:52 PM
<%response.write("Current date & time: "&now())%> Current date & time: 3/11/2010 10:51:52 PM
<%= FormatDateTime(Date, 0)%> 3/11/2010
<%= FormatDateTime(Date, 1)%> Thursday, March 11, 2010
<%= FormatDateTime(now, 3)%> 10:51:52 PM
<%= FormatDateTime(now, 4)%> 22:51
<%response.write("Day of the week: "&WeekDay(Date))%> Day of the week: 5
<%response.write("Day of the month: "&Day(Date))%> Day of the month: 11
<%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: Thursday
<%response.write("Hour Part: "&(hour(now)))%> Hour part: 22
<%response.write("Minute Part: "&Minute(now()))%> Minute part: 51
<%response.write("Second Part: "&Second(now()))%> Second part: 52
Loops Database Access