Just create a NSDateFormatter specifying the format of the expected date/time:

NSDateFormatter *dateExtracter = [[NSDateFormatter alloc] init];
[dateExtracter setDateFormat: @"yyyy-MM-dd'T'HH:mm:ss"];
[dateExtracter setTimeZone: [NSTimeZone timeZoneWithName:@"UTC"]]; // All 
date/times is received in UTC (if needed) 'Z' marks that the time is in UTC...

Then you just call:
NSDate *date = [dateExtracter dateFromString: @"2010-01-08T08:09:20Z"];

> 
> Hi,
> 
> I am having a time stamp string like 2010-01-08T08:09:20Z
> 
> I would like to know how I could convert this to a represented NSDate
> object.. Is it possible to do this without separating the string into
> several parts..
> 
> Thank you and Kind Regards,
> 
> tharindufit.wordpress.com
> 
> 

 
 
Regards.



Marcus Grenängen, Software Engineer
SourceTech AB
Phone: +46 (0)8 447 63 03
Cellphone: +46 (0)702 474 297
Email: mar...@sourcetech.se
Web: http://www.sourcetech.se
Blog: http://grenangen.se
 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to