简体   繁体   中英

Setting date format for particular string format in ios

I'm trying to set NSDateFormatter for the below string:

   2012-12-18T09:05:24.000Z 

It's the output of S3Object Summary lastmodifed object. What is the format I have to set it to if I need to change the display format?Any idea?

NSString *stringe = @"2010-06-21T20:06:36+00:00";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];

NSDate *reqDate = [dateFormatter dateFromString:string];
NSLog(@"%@",[dateFormatter stringFromDate:reqDate]);

Now you will get the date in NSDate object so you can change that date to as per your requirement.

For 2012-12-18T09:05:24.000Z

The format string is yyyy-MM-dd'T'HH:mm:ss.SSS'Z'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM