Can't convert from NSString to NSDate

前端 未结 2 902
孤街浪徒
孤街浪徒 2021-01-27 08:33

I can\'t convert my NSString to NSDate. here\'s the code:

+ (NSDate *) stringToNSDate: (NSString *) dateString{
[NSDateFormatter setDefaultFormatterBehavior:NSDa         


        
2条回答
  •  北海茫月
    2021-01-27 09:11

    Try this instead:

    [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
    [dateFormatter setDateFormat:@"yyyy/MM/dd HH:mm:ss ZZZ"];
    

提交回复
热议问题