Javascript’s Date object makes date handling fairly easy. One of the most useful features of this object is that it allows you to make direct comparisons of dates so that you can work out which date is larger or smaller, using the standard equality operators directly on the objects without having to convert the date to a timestamp first.

The Date object can be instantiated either with parameters specifying the date to set or else it defaults to the current date.

The format for a datestring which the Date object will accept is very specific, and needs to be month day, year hours:minutes:seconds, otherwise Javascript will complain. This limits the usefulness of this, and, depending on your application, will probably be better to specify the components individually.

For a full listing of the available methods of the Date object, have a look at this page

Share