ECMAScript 5's Date Extensions
One of the changes that ECMAScript 5 introduces is extensions to the Date class. Some of these are very useful — Date.now and Date.UTC as well as ISO-8601 format support.
Michael J. Ryan has written support for these API changes in DateExtensions.js so you can get started using them now.
Usage looks like this:
var epoch1 = new Date("1970-01-01T00:00:00.000Z");
var epoch2 = new Date(0);
if (epoch1.getTime() == epoch2.getTime())
alert("Epochs match!");
alert(epoch1.toString()); //localized date instance of the JS epoch
alert(epoch2.toISOString()); // "1970-01-01T00:00:00.000Z"
alert(epoch1 instanceof Date); // true
alert(Date.UTC(1970,0,1,0,0,0,0)); // 0
More on ECMAScript
Other ECMAScript 5 extensions to the base library include:
bind()that works like Prototype’s bind- A JSON object that supports parsing and generation
- New object/property extensions: ECMAScript 5 Objects and Properties
- String now has a
trim()method Arraygets useful methods likefilter()andmap()
You can read a PDF of the spec here: ECMA-262.pdf
