I am trying to create the formatter for parsing Fri, 12 Feb 2016 17:09:53 +0800 (SGT)
date format.
I tried using EEE, dd MMM yyyy HH:mm:ss Z
, but the output was null.
Any ideas as to how to parse the above date using NSDateFormatter
.
Thank you in advance.
PS - Tagged in Gmail API, since I was receiving the same from its response.
set Date format as
Uppercase Z for a numeric time zone offset
EEE, dd MMM yyyy HH:mm:ss ZZZ (zzz)
for additional Information see this link
Its better to handle Timezone separate from NSDate
as NSDate
store a point in time with either your local timezone or UTC timezone . Its upon you to handle these timezone.
So I would recommend that you cut off the time zone in parenthesis and just parse the numerical time zone offset before it. That way, you can convert all strings into an NSDate instance in UTC and you shouldn't have any problems parsing the strings.
Use this format: @"ccc, d LLL YYYY HH:mm:ss Z"
Reference took from and for more help regarding NSDateFormatter you can create your date format more easily from this link .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.