【发布时间】:2012-06-12 12:56:34
【问题描述】:
试图证明我可以将NSString 转换为NSDate 的简单案例。创建一个NSDate,将其转换为NSString,然后再转换为NSDate。日期作为字符串看起来不错,但是当我将其转换回来时,我总是会得到一些日期,例如 12/25/2011 .... 有人能发现我的错误吗?
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"dd/MM/YY hh:mm a"];
NSDate* b = [[NSDate alloc] init];
NSString* f = [df stringFromDate:b]; // has the current date and time
NSDate* dt =[df dateFromString:f]; // 12/25/2011 - where does it get this?
【问题讨论】:
标签: ios ios5 nsdate nsdateformatter