-1

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 ?

PaolaJ.
  • 10,872
  • 22
  • 73
  • 111

1 Answers1

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];
Hafthor
  • 16,358
  • 9
  • 56
  • 65
Anupdas
  • 10,211
  • 2
  • 35
  • 60