标签:
代码:
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //调用获得现在日期的函数。 [self getDateFromLocal]; } //获得现在的日期。格式:2015-03-11 -(NSString*)getDateFromLocal{ NSDate * senddate=[NSDate date]; NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init]; [dateformatter setDateFormat:@"YYYY-MM-dd"]; NSString * locationString=[dateformatter stringFromDate:senddate]; NSLog(@"locationString:%@",locationString); return locationString; }
输出:
2015-03-11 15:42:08.258 获得现在的日期[4983:197931] locationString:2015-03-11
标签:
原文地址:http://www.cnblogs.com/yang-guang-girl/p/4330111.html