Classic ASP current date and time with Date, Time and Now

Classic ASP executes VBScript on the web server, so Date, Time and Now use the server's current clock and regional settings. They do not automatically return the visitor's local time.

Client-time note: if you need the visitor's browser time zone or local clock, collect it on the client (for example with JavaScript) and send the value to the server.

Get the current date

d_today = Date

Date returns the current server date without a time component.

Dim d_today
d_today = Date
Response.Write d_today

Get date and time with Now

Dim d_today
d_today = Now
Response.Write d_today

Now returns the current server date and time.

Get only the current time

d_today = Time

Regional formatting with SetLocale

Dim d_today, previousLocale
previousLocale = SetLocale(2057) ' English (United Kingdom)
d_today = Now
Response.Write FormatDateTime(d_today, vbGeneralDate)
SetLocale previousLocale

SetLocale() changes locale-sensitive formatting and parsing for the script context. Save the previous locale and restore it if the page temporarily switches locale.

VBScript Date & Time functions

TopicUse
FormatDateTime()Display date/time using named regional formats.
DateAdd()Add or subtract years, months, days, hours and other intervals.
DateDiff()Count specified interval boundaries between two dates.
DatePart()Extract year, month, day, week or other parts.
MonthName()Convert a month number to its localized name.
Weekday() / WeekdayName()Find weekday numbers and names.
DateSerial()Build a Date value from year, month and day components.
IsDate()Test whether a value can be interpreted as a date.
Validate user-entered datesBuild and verify dates from separate form fields.

ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer