0
を示すミリ秒とNSDateFormatter現在の日付、私は次の形式で現在の日付を生成するNSDateを実装しようとしています:のiOS:ダッシュ
2017-06-14T15:38.000Z
は、私は次の実装を試してみました:
-(void)currentDate
{
NSDate *date = [NSDate date];
NSDateFormatter *formatter = [NSDateFormatter new];
NSTimeZone *destinationTimeZone = [NSTimeZone systemTimeZone];
formatter.timeZone = destinationTimeZone;
[formatter setDateStyle:NSDateFormatterLongStyle];
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.ZZZ"];
NSString *dateString = [formatter stringFromDate:date];
NSLog(@"%@",dateString);
}
しかし、これは私が得るフォーマットの文字列です:
2017-06-14T14:08:56.-0700
どのようにm y NSDateFormatterを使用して、次の日付形式を取得します。
2017-06-14T15:38.000Z
本当にありがとうございます。
.000Zはミリ秒ではありませんが、UTCの時刻にdiference尊重 –
@ReinierMelianである、あなたは説明できますか? – user2924482
この形式はyyyy-MM-dd'T'HH:mm:ss.ZZZは年、月、日、時、時、分、秒であり、ZZZはUTC時間との時差です。 -7hrsの違いがあります –