java默认日期格式等效于目标C.

时间:2014-05-15 09:15:27

标签: objective-c nsdate

当我们在java(new Date())中获取日期时,格式为“Tue May 13 13:37:06 UTC 2014”。如何在目标c中获得此格式?

1 个答案:

答案 0 :(得分:0)

这就是你得到的...... .. :)

 NSDate *newDate = [NSDate date];

 NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

 [formatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"]; // set here your own

 NSString *currentDate = [formatter stringFromDate:newDate];