JSON文字列(/ Date(1324435876019-0000)/)を作成するために、ローカル日付([NSDate date])をGMTに変換します。NSDate to JSON形式
私のタイムゾーンをPSTに変更すると、自分の時計をESTタイムゾーンに設定すると、自分のコードが正常に動作します。私のコードはESTとして動作します。あなたは次のコードが問題であることを教えてください。
NSDate *localDate = [NSDate date];
NSTimeInterval timeZoneOffset = [[NSTimeZone systemTimeZone] secondsFromGMT]; // You could also use the systemTimeZone method
NSTimeInterval gmtTimeInterval = [localDate timeIntervalSinceReferenceDate] - timeZoneOffset;
NSDate *gmtDate = [NSDate dateWithTimeIntervalSinceReferenceDate:gmtTimeInterval];
NSString *time = [NSString stringWithFormat:@"/Date(%@-0000)/", [NSNumber numberWithLongLong:[gmtDate timeIntervalSince1970] * 1000]];
現在時刻が2011年12月20日午前5時15分00秒0000しかし、私が出てきています私のNSLog gmtDateが1と置けば)ESTティムゾーンです:2011-12-21 3:15: 00 +0000 2)PSTタイムゾーン:2011-12-21 06:15:00 +0000。どちらが間違っている。私はGMTの日付が正しくないと思う。あなたが思うこと ? – AAV