0

example:

var temp = 'Thu Jan 09 2014 14:49:18 GMT-0500 (Eastern Standard Time)';
var testDate = new Date(temp);
alert(testDate);

The alert will read 'Invalid Date'

Now if I change it to:

var testDate = new Date('Thu Jan 09 2014 14:49:18 GMT-0500 (Eastern Standard Time)');
alert(testDate);

The alert will read: Thu Jan 09 2014 14:49:18 GMT-0500 (Eastern Standard Time)

The issue is that I am being given date strings in an array and if I set up my data:

for(i in array){
    alert(new Date(array[i]));
}

And because of the above example I am getting 'invalid date' in IE and iOS (I am running chrome app in iOS) It works fine in Chrome/firefox on desktop, what can I do to make Date() work correctly in IE and on iOS. Again, I am doing this in javascript and will not have access to the internet so online src="" links will not work.

  • 1
    Is it possible to get date strings that are valid RFC2822 dates? If not, can you convert your strings to valid RFC2822 dates? – Kevin Ji Jan 09 '14 at 20:13
  • Where are your date strings coming from? – gen_Eric Jan 09 '14 at 20:26
  • The strings come in from a servlet that called a database stored procedure and got a date string back. An example of the exact string it would send back is: "2014-01-03 08:00:00" – user3017876 Jan 09 '14 at 20:51
  • 1
    I would then use the server to convert the date string to the appropriate format. – Kevin B Jan 09 '14 at 20:53
  • possible duplicate of [Which date formats are IETF-compliant RFC 2822 timestamps?](http://stackoverflow.com/questions/14914739/which-date-formats-are-ietf-compliant-rfc-2822-timestamps) – Paul Sweatte Feb 13 '14 at 01:00
  • I suggest to send timestamps in milliseconds (or seconds) over the network. No parsing error can happen here. – sjngm Feb 13 '14 at 09:57

0 Answers0