all I want is a date like this: 01/06/1973 as an NSDate.
I assumed this would do the trick:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
NSDate *myDate =[dateFormatter dateFromString:@"01/06/1973" ];
but my formatting is not being followed
Your code would need to be slighty modified, like this:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"MM/dd/yyyy"];
oldestDate =[dateFormatter dateFromString:@"01/06/1973" ];
Hope it helps!
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"dd/MM/yyyy"];
NSDate *myDate =[dateFormatter dateFromString:@"01/06/1973" ];
您是否尝试过@“ mm / dd / yyyy hh:mm:ss”作为格式字符串?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.