Convert ms timestamp to NSString date
I know a lot of iOS conversion questions have been asked before but I just can't find a way to solve my problem.
I'd like to convert a millis开发者_如何学运维econds timestamp (i.e. 1299970800) to a correct, human readable date, but how?
Something like "12 Mar 2011" is enough. Thank you!
Use dateWithTimeIntervalSince1970
[NSDate dateWithTimeIntervalSince1970:(ms / 1000)];
assuming ms
holds the number of milliseconds since unix epoch in an integer or long.
You can use NSTimeInterval timeInterval = [date timeIntervalSinceNow]; then use seconds, minutes and hours as shown in the below code snippet to get readable date.
Readable Date for iOS
精彩评论