开发者

NSString TO NSDate Conversion

I Have a开发者_开发知识库 String.

     NSString *str=@"January-06-2012";

How would I convert the above NSString like this.

    @"2012-01-06 00:00:00 +0000";

Thanks


Use NSDateFormatter class .. YOu would need two of them .. one to convert your NSString* str to a date using [dateformatter dateFromString] and then another to convert your newly created date object to the differently formatted string using [dateformatter1 stringFromDate]

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/Reference/Reference.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜