`
zjjzmw1
  • 浏览: 1354766 次
  • 性别: Icon_minigender_1
  • 来自: 开封
社区版块
存档分类
最新评论

ios 不用考虑时区问题的方法。

    博客分类:
  • iOS
阅读更多

+(NSString *)fromTimeToChui:(NSDate *)date

{

    //把获取的时间转化为当前时间---->下面这几句以后就不用再考虑时区问题了。。。

    NSTimeZone *zone = [NSTimeZonesystemTimeZone]; //时区

    NSInteger interval = [zone secondsFromGMTForDate:date];

    NSDate *localeDate = [date  dateByAddingTimeInterval: interval];

    NSString *timeSp = [NSString stringWithFormat:@"%ld", (long)[localeDate timeIntervalSince1970]];

    return timeSp;

 

}

1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics