1。NSDate 转换成 字符串
NSDate convert to NSString:
NSDate convert to NSString:
1.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
2.
[dateFormatter setDateFormat:@
"yyyy-MM-dd HH:mm:ss"
];
3.
NSString *strDate = [dateFormatter stringFromDate:[NSDate date]];
4.
NSLog(@
"%@"
, strDate);
5.
[dateFormatter release];
2。 字符串转换成NSSdate:
NSString convert to NSDate:
1.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
2.
[dateFormatter setDateFormat:@
"yyyy-MM-dd HH:mm:ss"
];
3.
NSDate *date = [dateFormatter dateFromString:@
"2010-08-04 16:01:03"
];
4.
NSLog(@
"%@"
, date);
5.
[dateFormatter release];
本文转自编程小翁博客园博客,原文链接:http://www.cnblogs.com/wengzilin/archive/2012/03/16/2400655.html,如需转载请自行联系原作者