【发布时间】:2023-03-19 04:54:02
【问题描述】:
NSDate *date = [NSDate date];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"hh:mm a"];
[df setTimeZone:[NSTimeZone systemTimeZone]];
[df setLocale:[NSLocale systemLocale]];
NSLog(@" >> %@ >>> %@",date,[df dateFromString:@"12:18 AM"])
日志是
>> 2014-04-10 07:00:48 +0000 >>> 2000-01-01 06:52:00 +0000
我希望第二个日期也与第一个日期相同。
喜欢
2014-04-10 07:00:48 +0000 >>> 2014-04-10 06:52:00 +0000
【问题讨论】:
-
如果你不输入月/日/年,那将很难...尝试使用
NSDateComponents。
标签: ios iphone ipad nsdateformatter