Javascript provides a variety of functions for getting the date and time using both universal and local time.
| Time | Function | Result | Comment |
|---|---|---|---|
| Local | getFullYear() | ||
| Local | getYear() | Deprecated in javascript 1.2 | |
| Local | getMonth() | Starts with 0 for January. | |
| Local | getDay() | Starts with 0 for Sunday. | |
| Local | getHours() | 24 hour clock. | |
| Local | getMinutes() | ||
| Local | getSeconds() | ||
| Local | getMilliseconds() | ||
| Local | getTime() | In milliseconds. | |
| Local | getTimezoneOffset() | from GMT | |
| Local | toLocaleString() | Local date as a string | |
| Universal | getUTCFullYear() | ||
| Universal | getUTCMonth() | Starts with 0 for January | |
| Universal | getUTCDate() | Day of the month | |
| Universal | getUTCDay() | Starts with 0 for Sunday. | |
| Universal | getUTCHours() | ||
| Universal | getUTCMinutes() | ||
| Universal | getUTCSeconds() | ||
| Universal | getUTCMilliseconds() | ||
| General | toUTCString() | UTC date as a string. | |
| General | toGMTString() | Depracated in javascript 1.2. | |
| General | toString() | Converts a date to a string. | General | valueOf() | Converts a date to a number. |
Javascript provides a variety of functions for setting the date and time.
To be continued.Back to top Home Serious Stuff
© 2001. Copyright Sue Nethercott.