https://www.ietf.org/rfc/rfc3339.txt

https://zhuanlan.zhihu.com/p/31829454

-(NSString *)rfc3339DateFormatterStringToUTC8EndMicrosecond;{

//    2020-05-22T12:42:39.336702Z 格林尼治时间转本地时间  时间格式转换

    NSString *result = [NSString stringWithFormat:@"%@Z",[self substringToIndex:self.length - 8]] ;

    NSDateFormatter *rfc3339DateFormatter = [[NSDateFormatter alloc] init];

    NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];

    

    [rfc3339DateFormatter setLocale:enUSPOSIXLocale];

    [rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];

    [rfc3339DateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];

    

//    NSDate对象会自动根据当前时区加减时间 从而展示为当前时间

    NSDate *createdAtZero = [rfc3339DateFormatter dateFromString:result];

    NSDateFormatter *showDateFormatter = [[NSDateFormatter alloc] init];

    //    2019/11/16 23:12:34

    [showDateFormatter setDateFormat:@"yyyy/MM/dd HH:mm:ss"];

    result = [showDateFormatter stringFromDate:createdAtZero];

    return result;

}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2022-01-24
  • 2021-07-10
  • 2022-02-28
猜你喜欢
  • 2022-02-22
  • 2021-07-22
  • 2021-12-11
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案