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;

}

猜你喜欢

转载自zhangmingwei.iteye.com/blog/2079664