开发者

Convert ms timestamp to NSString date

开发者 https://www.devze.com 2023-02-18 11:25 出处:网络
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 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

0

精彩评论

暂无评论...
验证码 换一张
取 消