开发者

question related to conversion from NSDate to NSString

开发者 https://www.devze.com 2022-12-14 07:45 出处:网络
NSString *abc = @\"2009-12-12 16:25:00\"; i have 1 string in this format as shown above. NSDate *currentDate = [NSDate date];

NSString *abc = @"2009-12-12 16:25:00";

i have 1 string in this format as shown above.

NSDate *currentDate = [NSDate date]; now i want currentDate in also this format as specified 2009-1开发者_运维问答2-12 16:25:00

and also i want to convert this currentDate from NSdate to NSString format with specified thisformat 2009-12-12 16:25:00

help me


    NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString* golly = [dateFormatter stringFromDate:[NSDate date]];


Use NSDateFormatter.

0

精彩评论

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