Get Current Date/Time
The first example just shows you how to get the current date and time. Note that this can vary slightly depending upon the browser. Also, it does not factor in your time zone.
Thu Aug 6 22:49:52 EDT 2009 Thu Aug 06 2009 19:43:34 GMT-0400 (Eastern Daylight Time)
UTC (Coordinated Universal Time) String
This example gets the date and time in a slightly different string format.
Thu, 6 Aug 2009 22:49:52 UTC Thu, 06 Aug 2009 23:44:14 GMT
UTC (Coordinated Universal Time) Number
The UTC() method takes a date and returns the number of milliseconds since midnight of January 1, 1970 according to universal time. 10 to 13 digits, last 3 digits for miliseconds.
The example above converts a UTC date in the numerical format, 1249585988774, into the string format. This is what I needed to work with the Reddit API.
ISO 8601. Note that the “T” appears literally in the string, to indicate the beginning of the time element. Times are expressed in UTC (Coordinated Universal Time), with a special UTC designator (“Z”). Used in ATOM RSS feeds.
Since the toISOString() method is not available for Internet Explorer yet you will need to reformat a date into the ISO 8601 format yourself. The following code is just one way to accomplish this: