我将日期记入string
。 date format
是这样的,string
是
datenotification=20-02-2012
现在我想将其更改为
20-feb-2012
但出于检查目的,我只是将其放入dateformatter
并打印出来,但它显示的日期不正确
NSDateFormatter* currentdateformate = [[NSDateFormatter alloc] init];
[currentdateformate setDateFormat:@"dd-MM-YYYY"];
NSDate *d=[currentdateformate dateFromString:dateNotification];
NSString *str3=[currentdateformate stringFromDate:d];
[currentdateformate release];
答案 0 :(得分:2)
嘿检查这个例子
NSString *string = @"12-02-2000";
NSDateFormatter* currentdateformate = [[NSDateFormatter alloc] init];
[currentdateformate setDateFormat:@"dd-MM-yyyy"];
NSDate *d=[currentdateformate dateFromString:string];
[currentdateformate setDateFormat:@"dd-MMM-yyyy"];
NSString *str3=[currentdateformate stringFromDate:d];
[currentdateformate release];
NSLog(@"S %@",str3);
输出S 12-feb-2012