If I get string date in format @"MM/dd/YYYY h:mm a"
and I have timezone of date(string date), how can I convert this to UTC number ?
Asked
Active
Viewed 435 times
-1

PaolaJ.
- 10,872
- 22
- 73
- 111
-
1What do you mean by "timezone of date(string date)" ? Can you give a concrete example? – Martin R Mar 24 '13 at 17:11
-
r u looking smthing similar to [this](http://stackoverflow.com/questions/2615833/objective-c-setting-nsdate-to-current-utc) – Anoop Vaidya Mar 24 '13 at 17:12
-
Read the spec for NSDate? – Hot Licks Jun 28 '13 at 20:15
1 Answers
0
Try this
NSString *dateString = @"03/23/2012 09:17 PM";
//It is assumed that the time in dateString wrt local time zone
NSDateFormatter *dateFormatter = [NSDateFormatter new];
[dateFormatter setDateFormat:@"MM/dd/yyyy h:mm a"];
NSDate*date = [dateFormatter dateFromString:dateString];
NSTimeInterval timeInSeconds = [date timeIntervalSince1970];