[an error occurred while processing this directive]
javascript tutorial graphic

Webteacher Software now offers

//Define Date to display in local syntax
now = new Date();
LocalTime = now.toLocaleString();

Date Methods

Before you can do anything which involves the current date/time, you have to set a variable equal to the current date. now = new Date() is command to get the current date and time from the user's computer, and assign it to the variable, now in one long string.

toLocaleString() is a method which converts the raw date/time string of text into the local convention. Depending on what country JavaScript thinks the user is in, the toLocaleString() may present the month first, or the day first.

now =
now.toLocaleString() =

Here are some other Date methods:
If now =
now.getDay()= Day of week (0=Sunday)
now.getMonth()= Month (0 to 11)
now.getDate()=Day of month
now.getYear()= Year
Note: IE returns a 4 digit year, Netscape returns the number of years since 1900. Use this syntax:
if (year<1900) {year+=1900};
now.getHours()= Hours
now.getMinutes()= Minutes
now.getSeconds()= Seconds
..........Milliseconds since January 1, 1990 at Midnight.
now.gettimezoneOffset()= minutes off from GMT

Next Page

Home | WebData - Web Database Software | Javascript | CGI | Consulting | Map Builder | Contact Us | The Press Room