The Date object has methods for manipulating dates and times. JavaScript stores dates as the number of milliseconds since January 1, 1970. The sample below shows the different methods of creating date objects, all of which involve passing arguments to the Date() constructor.

A few things to note:

To create a Date object containing the current date and time, the Date() constructor takes no arguments.

When passing the date as a string to the Date() constructor, the time portion is optional. If it is not included, it defaults to 00:00:00. Also, other date formats are acceptable (e.g, "11/06/2009" and "11-06-2009").

When passing date parts to the Date() constructor, dd, hh, mm, ss, and ms are all optional. The default of each is 0.

Months are numbered from 0 (January) to 11 (December).

Some common date methods are shown below. In all the examples, the variable RIGHT_NOW contains "Fri Nov 06 00:23:54:650 EDT 2009".