iPhone - 问题NSDate根据当前时区获取时间间隔
问题描述:
我正在使用NSDate根据当前时区获取NSTimeInterval。 但我收到有关UTC的信息。 我使用的方法,如“dateWithTimeIntervalSinceNow”和“dateWithTimeIntervalSince1970” 我如何获得时间间隔按照我的时区?iPhone - 问题NSDate根据当前时区获取时间间隔
答
如果两者都NSDates那么你可以做:
//calculate the time difference in seconds, that is absolute and does not depend in time zones :)
double timeDiffInSecs = [date1 timeIntervalSince1970] - [date2 timeIntervalSince1970];
我只是想为当前时间的当前时间间隔区域而不是UTC – Satyam