ios - 后台给的时间戳 4s上显示的是1970.1.14 而5s上是正确时间2016.3.5。
PHP中文网
PHP中文网 2017-04-17 17:37:46
0
3
295

4s是7.1
5s是9.2
百度找不到答案,感觉是系统问题,下面是代码

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:[self.appointmentServiceTime integerValue]/1000];
[formatter setDateFormat:@"YYYY.MM.dd"];
NSString *str = [formatter stringFromDate:confromTimesp];

我又用模拟器测试了一下,发现存在同样的问题,也就是说跟手机型号有关,系统版本无关,请问如何适配?
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
刘奇

Send the value of appointmentServiceTime. appointmentServiceTime 的值发一下。

应该是你[self.appointmentServiceTime integerValue]这个的问题,
换成doubleValue就都一样了。
应该是4s上integerValue是int_32,
而是5s上integerValue是int_64,
所以你的1457107200000
It should be your [self.appointmentServiceTime integerValue] problem. If

is replaced with doubleValue, it will be the same. #🎜🎜# should be that integerValue is int_32 on 4s, #🎜🎜# but integerValue is int_64 on 5s, #🎜🎜# so your 1457107200000This value is greater than the range of 32-bit int values. #🎜🎜#So there is a problem on 4s. #🎜🎜#
PHPzhong

You can just parse it directly into Y-m-d H:i:s and give it to the client

巴扎黑

Please refer here:

http://www.henishuo.com/ios-timestamp-date-converted/

Written an extension, which is often used in development

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!