The Date() object
There are four ways of instantiating a date object:
new Date(); // Today's date, now.
Here are a few examples of instantiating a date:
Many methods exist for extracting details from the date object, for example:
You can also set the properties of the object with methods. So you can create date objects for times in the future or the past. There are also methods for representing the date in different ways. For example:
The above will convert the current date into a format that is frequently used for databases and "last modified" date stamps (Universal Time code):
A similar method, toGMTString() is useful for creating future expiration times for cookies.