The Date object in JavaScript.
var myDate = new Date(DateInfo)
Here are the various possibilities for DateInfo:
(). The current local date and time.(stampInMS). Milliseconds since midnight 01 January, 1970 UTC. The reference date is known as Unix epoch. Unix time is actually seconds since Unix epoch.(dateString). Usual date strings such as "February 28, 1969", "Mon, 25 Dec 1995 13:30:00 GMT", "Mon, 25 Dec 1995 13:30:00 GMT+0430". See .parse() below.(year, month, date[, hour[, min[, sec[, ms]]]]). 1000-9999, 0-11 where 0=Jan, 1-31, 0-23, 0-59, 0-59, 0-9999.A JavaScript date is measured in milliseconds since midnight 01 January, 1970 UTC (1970-01-01 00:00:00). A day holds 86,400,000 ms. The Date object range is -100,000,000 days to 100,000,000 days relative to 01 January, 1970 UTC.
Try to use the FullYear variations instead of Year variations.
These methods get/retrieve some portion of its date object. Unless otherwise noted, all are implemented JS 1.0; ECMA-262. The variations include:
dtm.valueOf().The UTC variations temporarily converts the date object to UTC. Magically adjusts for daylight saving time. Unless otherwise noted, all are implemented JS 1.3; ECMA-262.
Note that there is no getUTCTime(), getUTCTimezoneOffset(), or getUTCYear().
Implemented: JS not; ECMA-262 not.
Static method
Returns milliseconds since midnight 01 January, 1970 UTC for the system date and time. [This isn't part of any standard but is part of many common libraries.]
var d = new Date(); d.now(); //Won't work Date.now(); //OK
Implemented: JS 1.0; ECMA-262.
Static method
Returns milliseconds since midnight 01 January, 1970 UTC for the given datetime string. Parse takes datetime strings like the following:
"Mon, 25 Dec 1995 13:30:00 GMT". http://tools.ietf.org/html/rfc822#section-5
date-time = [ day "," ] date time ; dd mm yy
; hh:mm:ss zzz
day = "Mon" / "Tue" / "Wed" / "Thu"
/ "Fri" / "Sat" / "Sun"
date = 1*2DIGIT month 2DIGIT ; day month year
; e.g. 20 Jun 82
month = "Jan" / "Feb" / "Mar" / "Apr"
/ "May" / "Jun" / "Jul" / "Aug"
/ "Sep" / "Oct" / "Nov" / "Dec"
time = hour zone ; ANSI and Military
hour = 2DIGIT ":" 2DIGIT [":" 2DIGIT]
; 00:00:00 - 23:59:59
zone = "UT" / "GMT" ; Universal Time
; North American : UT
/ "EST" / "EDT" ; Eastern: - 5/ - 4
/ "CST" / "CDT" ; Central: - 6/ - 5
/ "MST" / "MDT" ; Mountain: - 7/ - 6
/ "PST" / "PDT" ; Pacific: - 8/ - 7
/ 1ALPHA ; Military: Z = UT;
; A:-1; (J not used)
; M:-12; N:+1; Y:+12
/ ( ("+" / "-") 4DIGIT ) ; Local differential
; hours+min. (HHMM)
"12/25/1995 2:00 PM". Note that 2 digit years are assumed to be in the 1900s. Variations such as P.M., pm, and p.m. are also accepted."Dec 25, 1995 2:00 PM". Variations such as P.M., pm, and p.m. are also accepted.
//Unless you are locally in GMT, these should return different values
alert(Date.parse("Mon, 25 Dec 1995 13:30:00"));
alert(Date.parse("Mon, 25 Dec 1995 13:30:00 GMT"));
These methods set/specify some portion of its date object. Unless otherwise noted, all are implemented JS 1.0; ECMA-262.
dtm.valueOf().Note that there is no setDay(), setTimezoneOffset(), setYear().
The UTC variations temporarily converts the date object to UTC then set the value of its date object. Magically adjusts for daylight saving time. Unless otherwise noted, all are implemented JS 1.3; ECMA-262.
Note that there is no setUTCTime().
These methods usually translate a date object (or a portion of it) to a string of particular formats. Unless otherwise noted, all are implemented JS 1.0; ECMA-262. The variations include:
Wed Jul 28 1993.Mon, 18 Dec 1995 17:28:35 GMT
. Implemented: JS 1.0; JS 1.3 deprecated in favor of .toUTCString(); ECMA-262.12/18/95.strftime() [http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html] (part of the time.h header file). EG: .toLocaleFormat("%A, %B %e, %Y"); may return something like Wednesday, October 3, 2007.12/18/95 17:28:35
.17:28:35.Wed Sep 17 2008 11:46:36 GMT-0500 (Central Daylight Time). Overrides Object.toString().14:39:07 GMT-0600 (PDT).Mon, 03 Jul 2006 21:44:38 GMT
. Implemented: JS 1.3; ECMA-262.Implemented: JS 1.0; JS 1.3 added ms parameter; ECMA-262.
Static method
1000-9999, 0-11 where 0=Jan, 1-31, 0-23, 0-59, 0-59, 0-9999. Returns milliseconds since midnight 01 January, 1970 UTC.EG:
var d = new Date(); d.UTC(2008,3); //Won't work Date.UTC(2008,3); //OK
Page Modified: (Hand noted: 2007-08-08 17:58:30Z) (Auto noted: 2008-09-24 18:10:01Z)