哈,我知道如何在iphone中形成日期,但我必须将日期设置为下图所示。我的代码是
NSDate* date = [NSDate date];
//Create the dateformatter object
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
//Set the required date format
[formatter setDateFormat:@"yyyy:mm:dd"];
//Get the string date
NSString* str = [formatter stringFromDate:date];
//Display on the console
// NSLog(str);
//Set in the lable
[_lbldateLabel setText:str];
如何修改上面的代码以获取图像给出的当前日期? 提前谢谢。
答案 0 :(得分:1)
try this
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
//Set the required date format
[formatter setDateFormat:@"MMM dd/yy"];
//Get the string date
NSString* str = [formatter stringFromDate:date];