Stas
Stas

Reputation: 9935

Date formatter for a certain format of date

I might missing something, but I can't compose proper date formatter string for the date:

2016-01-14T10:24:26+0000

What is 'T' here? and how to include timezone?

My string does not work: @"yyyy-MM-dd'T'hh:mm:ss Z"

Upvotes: 1

Views: 127

Answers (2)

Kishor Kumar Rawat
Kishor Kumar Rawat

Reputation: 910

NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'";     
NSDate *yourDate = [dateFormatter dateFromString:myString];

Upvotes: 0

Jaimish
Jaimish

Reputation: 629

You have to use 'T' in single quotes like below format to retrive string ftom date:

yyyy-MM-dd'T'hh:mm:ssZ

Let me know.

Upvotes: 3

Related Questions