Invalid Javascript Date in iOS / Android 2.2

I have this line containing a date that I need to parse to get a javascript Date object. It works if I execute the code in the PC browser, but give me an invalid date if I launched the web page in iOS (I tried iPhone 4.3) and the Android 2.2 emulator.

<body>
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
</head>
<html>
<script type="text/javascript">
$(document).ready(function(){
  var date = new Date('2011-03-04T08:14:00+01:00');
  $('#test').html(date.toString());
});
</script>
<div id="test"></div>
</html>
</body>

Does anyone know what could be wrong? I can always parse the date manually (given that it will always be in the same format), but in any case it seems to me that the problem is with a terrible problem.

Hooray!

+5
source share
1 answer

Date actually invalid:

tjwebb@latitude:~$ rhino
Rhino 1.7 release 2 2010 09 15
js> var date = new Date('2011-03-04T08:14:00+01:00');
js> date.toString();
Invalid Date
js> 

JavaScript- Rhino, Mozilla, .

-tjw

+2

All Articles