Convert milliseconds to NSDate

前端 未结 3 765
慢半拍i
慢半拍i 2020-11-28 14:58

I have this \"1273636800000\" and I want to convert it to this format \"Wed Mar 03 2010 00:00:00 GMT-0500 (EST)\"

I need to convert this milliseconds to NSDate forma

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 15:12

    These functions (dateWithTimeIntervalSince1970, dateWithTimeIntervalSinceReferenceDate, dateWithTimeIntervalSinceNow) accept parameter in seconds.

    NSDate *date = [NSDate dateWithTimeIntervalSince1970:(ms / 1000.0)];
    

    You should pass 1273636800.000

    NSDate *date = [NSDate dateWithTimeIntervalSince1970:(1273636800 / 1000.0)];
    

提交回复
热议问题