陈斌彬的技术博客

Stay foolish,stay hungry

NSDate获得当前应用程序系统时间

NSTimeZone *zone = [NSTimeZone defaultTimeZone];//获得当前应用程序默认的时区
NSInteger interval = [zone secondsFromGMTForDate:[NSDate date]];//以秒为单位返回当前应用程序与世界标准时间(格林威尼时间)的时差
NSDate *localeDate = [[NSDate date] dateByAddingTimeInterval:interval];
NSDate *nowDate=[NSDate dateWithTimeIntervalSinceNow:interval];

UIDatePicker *datePicker=[[UIDatePicker alloc] init];
[datePicker setDate:nowDate];

NSLog(@"datePicker==%@",[datePicker date]);
NSLog(@"interval===%i",interval);
NSLog(@"localeDate==%@",localeDate);
NSLog(@"nowDate==%@",nowDate);
NSLog(@" [localeDate description]==%@", [localeDate description]);