iOS NSDate获取当前时间并格式化

 NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
 NSString *dateTime = [formatter stringFromDate:[NSDate date]];
NSLog(@"formatted time is: %@",dateTime);

  

 NSTimeZone *zone = [NSTimeZone systemTimeZone];
NSInteger interval = [zone secondsFromGMTForDate:date];
 NSDate *localDate = [date dateByAddingTimeInterval:interval];
NSLog(@"localtime is:%@",localDate);

  

posted @ 2015-12-12 09:31  Ficow  阅读(565)  评论(0编辑  收藏  举报