I've got a date in the following format:
2013-05-04T05:07:09+00:00
I'm using MagicalRecord to map the NSDate automatically. As far as I can see the above date format should comply with MagicalRecord's default date format: yyyy-MM-dd'T'HH:mm:ss'Z'
.
I have tried with a custom dateFormat
entry in the attribute's user info (see this article):
yyyy-MM-ddTHH:mm:ss+Z
, yyyy-MM-dd T HH:mm:ss Z
, yyyy-MM-dd'T'HH:mm:ss'+'Z
but none of them work in order to have it parse the date properly and it always returns nil
regardless of setting a custom dateFormat
or using MagicalRecord's default format.
Let's look at your string:
2013-05-04T05:07:09+00:00
This is:
Thus, according to the date format specifiers documentation, the pattern you'd want is:
yyyy-MM-dd'T'HH:mm:ssZZZZZ
Also, be sure to use the en_US_POSIX
locale with the NSDateFormatter
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With