Hey guys, Im having trouble knowing wat is the correct date format i should put for date.parse() function.
I want to use mm/dd/yyyy in the function like this.
alert("Date: "+Date.parse("11/28/2011"));
//-->Its showing me Date:NaN as output.
also I wanted to know what output should I be getting if I do this following code:
date = Date.parse('12/31/2011' +' UTC');
var minutes=1000*开发者_运维百科60;
var hours=minutes*60;
var days=hours*24;
var years=days*365;
var y=date/years;
t should give me exactly 42 years but its giving me decimal as well. Y so??
Any help will be appreciated guys.
Thanks
Anand
International (ISO) standard date time format will always work. 2011-12-31
You may also look at this and this
Why would it give you exactly 42 years? Don't forget that there's no such thing as an exact number of milliseconds in a year, due to leap years (and leap seconds, if they're accounted for). Even if there were, you're getting the start of the last day of 2011, which isn't the same as the start of the first day of 2012, which is probably what you were thinking of.
The exact formats supported are implementation-specific as far as I can tell - at least for ECMAScript (which I realise isn't quite the same as JavaScript).
精彩评论