Use it
NSTimeInterval timeInMiliseconds = [[NSDate date] timeIntervalSince1970];
To change it,
NSDate* date = [NSDate dateWithTimeIntervalSince1970:timeInMiliseconds];
According to apple documentation,
NSTimeInterval: Used to indicate the time interval in seconds.
typedef double NSTimeInterval;
This is a double type.
To convert a date to a string,
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss zzz"];
idev
source share