pingjiang / datejs

Automatically exported from code.google.com/p/datejs
Other
0 stars 0 forks source link

toISOString() only works in Firefox #82

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
var d = new Date().toISOString();
alert(d);

What is the expected output? What do you see instead?
2009-08-06T23:59:44.535Z
JavaScript error

What version of the product are you using? On what operating system?
Internet Explorer 8, Opera 9.64, Google Chrome 2.0.172.39 and Safari 4.0.2 
on Vista.

Please provide any additional information below.

Message: Object doesn't support this property or method

Original issue reported on code.google.com by robbins0...@gmail.com on 7 Aug 2009 at 12:07

GoogleCodeExporter commented 9 years ago
I'm stuck on this problem at the moment

Original comment by vijay.sa...@gmail.com on 27 Sep 2009 at 1:27

GoogleCodeExporter commented 9 years ago
Same here on IE8. 
At least the documentation should be updated.

Original comment by dan.jul...@gmail.com on 21 Jul 2010 at 8:25

GoogleCodeExporter commented 9 years ago
Same here, changed to use toString instead.

Original comment by scko...@gmail.com on 6 Oct 2011 at 3:41

GoogleCodeExporter commented 9 years ago
Or change to "toJSONString"

Original comment by tokyo.t...@gmail.com on 8 May 2012 at 1:32

GoogleCodeExporter commented 9 years ago
Works fine on the current builds in my fork: 
http://github.com/abritinthebay/datejs/issues/82

Original comment by darkcr...@gmail.com on 15 Sep 2013 at 7:16

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
toJSON() works in IE8 mode but not real IE8!

function toISOString(date){
    var m = 1+date.getMonth()
    var d = date.getDay()
    return date.getFullYear()+"-"+(m<10?'0'+m:m)+"-"+(d<10?'0'+d:d)
}

Original comment by CTimmerm...@gmail.com on 3 Oct 2013 at 1:48

GoogleCodeExporter commented 9 years ago
@CTimmerm: thanks alot for sharing that routine! Besides just working, it's 
also very concise and yet still makes much shorter work of padding the leading 
zero for the date and month values than other solutions I came across on other 
sites like stakoverflow.

For my part, I would just suggest that your use of the date.getDay() method 
seems to deviate from both JSON or ISO standards... as it's grabbing the "day 
of the week" rather than the "the day of the month". Not sure if you can edit 
that post, but for posterity might be good to replace it with date.getDate().

Thanks again for sharing your workaround! Maybe one of these days I'll find an 
answer why none of the date object to<String> like methods work in system 
jscript tests on my Win7 system.

Original comment by stej...@gmail.com on 17 Jan 2014 at 1:01