【代码笔记】iOS-获得现在的日期

来源:互联网 发布:泡妞的软件排行 编辑:程序博客网 时间:2024/05/02 01:27

一,代码。

复制代码
- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.        //调用获得现在日期的函数。    [self getDateFromLocal];    }#pragma -mark -functions//获得现在的日期。格式: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-10-19 13:42:54.112 获得现在的日期[5520:126089] locationString:2015-10-19

 


0 0