Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Date.parse error

I'm trying to store a retrieved date d=string (from an rss feed) as a date object, but can't get past the Date.parse function.
Every example and test I try in regular browsers works:
d = Date.parse('2010-04-07T21:21:22+00:00')

(frankly, many differently formatted dates I try work in the browser, but not in the iphone…) I invariably get 'NaN' from the iphone version…

Anyone else struggling with Date issues?

— asked April 24th 2010 by david hoare
  • datetime
0 Comments

1 Answer

  • I struggled for a little while with dates as well, and found the following to work well for me:

    var myDate = new Date(dateString.replace(/-/g, '/'));
    

    I had to replace "-" characters with "/", and was just using the Date() constructor, but I believe Date.parse() is the equivalent.

    — answered April 25th 2010 by Brad Harris
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.