titanium sdk:2.1.1 os: mac os platform: iphone simulator 5.1
i met a very curious problem, please see following three lines of code, quite simple:
Ti.API.info(post.created_at); var _time = new Date(post.created_at); Ti.API.info(_time);the first info logs: 2012-10-03T01:54:38+0000 the second info logs: 1969-12--2147483629 -596:-31:-23 +0000, it seems that the new Date doesn't get the correct date. but on android platform, it gives me correct date.
I'm assuming that post.created_at contains the string "2012-10-03T01:54:38+0000". So it looks like on iOS, the Date() constructor isn't able to parse your date correctly. Whenever I see a December 1969 date, I know we're dealing with a zero- or null-value date (as measured in seconds from the UNIX epoch).
I don't know the intricacies of exactly what string formats would be recognized by the Date() constructor on both platforms, but it's possible that this date format isn't recognized by the Date() implementation on iOS. The format looks pretty straightforward, so I'm kind of surprised by that.
At any rate, you might want to consider moment.js to see if it can reliably parse the date format for you.
Or see if you can provide the
this post's answer can also solve my problem http://developer.appcelerator.com/question/125827/date-conversion-need-some-help#219201
Think you can help? Login to answer this question!