Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. - (void) dateConverter{
  2. NSString *string = [NSString stringWithFormat:@"%@ %@", [[self dates]objectAtIndex:0], [times objectAtIndex:0]]; // string = 01-10-2014 11:36 AM;
  3. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  4.  
  5. [dateFormatter setDateFormat:@"dd-MM-yyyy hh:mm a"];
  6. [dateFormatter setLocale:[NSLocale currentLocale]];
  7. NSDate *date = [[NSDate alloc] init];
  8.  
  9. date = [dateFormatter dateFromString:string];
  10. NSLog(@"dateFromString = %@", date); // 2014-10-01 18:36:00 +0000
  11.  
  12. NSTimeInterval timeInterval = [date timeIntervalSince1970];
  13. NSLog(@"dateFromString = %f", timeInterval); // 1412188560.000000
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement