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()%> 6:05:30 PM
<%=date()%> 5/11/2008
<%=now()%> 5/11/2008 6:05:30 PM
<%response.write("Current date & time: "&now())%> Current date & time: 5/11/2008 6:05:30 PM
<%= FormatDateTime(Date, 0)%> 5/11/2008
<%= FormatDateTime(Date, 1)%> Sunday, May 11, 2008
<%= FormatDateTime(now, 3)%> 6:05:30 PM
<%= FormatDateTime(now, 4)%> 18:05
<%response.write("Day of the week: "&WeekDay(Date))%> Day of the week: 1
<%response.write("Day of the month: "&Day(Date))%> Day of the month: 11
<%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: Sunday
<%response.write("Hour Part: "&(hour(now)))%> Hour part: 18
<%response.write("Minute Part: "&Minute(now()))%> Minute part: 5
<%response.write("Second Part: "&Second(now()))%> Second part: 30
Loops Database Access