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.
d_today = Date
Date returns the current server date without a time component.
Dim d_today
d_today = Date
Response.Write d_today
Dim d_today
d_today = Now
Response.Write d_today
Now returns the current server date and time.
d_today = Time
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.
| Topic | Use |
|---|---|
| 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 dates | Build and verify dates from separate form fields. |
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.