Reputation: 31
I have in variable value from PHP function mktime(time from epoch), exacly 133123088. How I can change it for readable date in iphone?
Is any function to convert this format to another like NSDate or just string ?
Upvotes: 0
Views: 569
Reputation: 27526
NSTimeInterval timeInterval = 133123088; // NSTimeInterval is a double
NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval];
Notice that 133123088
corresponds to a date in 1974. So I guess you are missing a digit in 133123088
to make it a date in 2012: For example : 1331230880
NSTimeInterval timeInterval = 1331230880;
NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy/MM/dd HH:mm:ss";
NSString *dateString = [formatter stringFromDate:date];
Upvotes: 1
Reputation: 9977
NSDate* date = [NSDate dateWithTimeIntervalSince1970: 133123088]
Upvotes: 1