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/Bookmark

Related posts:

  1. How to dump a Javascript object When trying to debug Javascript, objects can be a real...
  2. Dygraphs Javascript Visualization Library Drawing graphs has become simpler in Javascript, with the dygraphs...
  3. Astronomical calculations in C#: Sidereal time Sidereal time is the time in relation to the stars....
  4. Astronomical calculations in C#: Right ascension Before I move on to other stuff, let us talk...
  5. Assigning objects by value in Javascript Javascript can be a little bit of a quirky language...

Related posts brought to you by Yet Another Related Posts Plugin.