NsDateFormatter 格式化日期
NsDateFormatter format the date
我如何格式化这个日期?
2017 年 2 月 24 日 11:13:43 上午
我试过这段代码但没有成功
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM/dd/yyyy HH:mm:ss"];
NSString *stringDate = [dateFormatter stringFromDate:createdDate];
您需要更改日期格式。您需要 'a' 进入格式化程序。
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM/dd/yyyy hh:mm:ss aa"];
NSString *stringDate = [dateFormatter stringFromDate:[NSDate date]];
输出:
Printing description of stringDate:
02/25/2017 09:56:42 AM
您可以看到更多关于 dateFormate 的信息。
干杯
我如何格式化这个日期?
2017 年 2 月 24 日 11:13:43 上午
我试过这段代码但没有成功
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM/dd/yyyy HH:mm:ss"];
NSString *stringDate = [dateFormatter stringFromDate:createdDate];
您需要更改日期格式。您需要 'a' 进入格式化程序。
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM/dd/yyyy hh:mm:ss aa"];
NSString *stringDate = [dateFormatter stringFromDate:[NSDate date]];
输出:
Printing description of stringDate:
02/25/2017 09:56:42 AM
您可以看到更多关于 dateFormate 的信息。
干杯