NSDate问题

开发中的教训:

使用[NSDate date]获取到的是GMT时间,和中国时区相差8个小时,解决方案:将[NSDate date]转换成手机系统时间

//[NSDate date]获取的是GMT时间,下面获得某个时区的系统时间
+(NSDate *)getNowDateFromatAnDate:(NSDate *)anyDate{
    NSTimeZone *zone = [NSTimeZone systemTimeZone];
    NSInteger interval = [zone secondsFromGMTForDate: anyDate];
    NSDate *localeDate = [anyDate dateByAddingTimeInterval: interval];
    return localeDate;
}

你可能感兴趣的:(NSDate问题)