我用印度时区以GHM格式计算了我们的系统时间,但它显示了5小时的差异
答案 0 :(得分:1)
从服务器获取日期并转换为GMT格式,并与当地时区GMT时间(设备时间)进行比较。
//Assuming the dateString is in GMT+00:00
NSTimeZone *timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
[formatter setTimeZone:timeZone];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *date =[formatter dateFromString:dateString];