How do you convert any given date to milliseconds? For example, 2014-01-23 to timestamp conversion.
NSDate *date = [dateFormatter dateFromString:@"2014-01-23"];
NSLog(@"date=%@",date);
NSTimeInterval interval = [date timeIntervalSince1970];
NSLog(@"interval=%f",interval);
NSDate *methodStart = [NSDate dateWithTimeIntervalSince1970:interval];
[dateFormatter setDateFormat:@"yyyy/mm/dd "];
NSLog(@"result: %@", [dateFormatter stringFromDate:methodStart]);
Output result: 1970/30/01
Convert the current date/time to a timestamp:
// current date and time
let someDate = Date()
// time interval since 1970
let myTimeStamp = someDate.timeIntervalSince1970
See also