iOS Date Parsing Issue

Posted by Duncan McDougall on August 7, 2012

The following code example works fine in web browsers but returns “Invalid Date” when tested on iOS using PhoneGap. Now I’m not saying it’s an PG thing. That’s just happens to be wearing I’m calling the new Date(“2012-06″) example.

Solution

Split the string into parts and passing in the first two items in the array. Since January is 0 and December is 11, remember to take 1 from the month value. Should work.

If anyone has a cleaner way to do it drop it in the comments. Much appreciated.



comments powered by Disqus