Date

Lets you work with dates and times. Date is a core object.

Created by

The Date constructor:

new Date()
new Date("month day, year hours:minutes:seconds")
new Date(yr_num, mo_num, day_num)
new Date(yr_num, mo_num, day_num, hr_num, min_num, sec_num)

Parameters

month, day, year, hours, minutes, seconds

String values representing part of a date.

yr_num, mo_num, day_num, hr_num, min_num, sec_num

Integer values representing part of a date. As an integer value, the month is represented by 0 to 11 with 0=January and 11=December.

Description

If you supply no arguments, the constructor creates a Date object for today's date and time. If you supply some arguments, but not others, the missing arguments are set to 0. If you supply any arguments, you must supply at least the year, month, and day. You can omit the hours, minutes, and seconds.

The way JavaScript handles dates is very similar to the way Java handles dates: both languages have many of the same date methods, and both store dates internally as the number of milliseconds since January 1, 1970 00:00:00. Dates prior to 1970 are not allowed.

Examples

The following examples show several ways to assign dates:

today = new Date()
birthday = new Date("December 17, 1995 03:24:00")
birthday = new Date(95,11,17)
birthday = new Date(95,11,17,3,24,0)