首页 > 其他 > 详细

日期,时区

时间:2015-03-26 10:29:10      阅读:258      评论:0      收藏:0      [点我收藏+]

    NSDateFormatter *format = [[NSDateFormatter alloc] init];

    [format setLocalizedDateFormatFromTemplate:@"yyyy-MM-dd HH:mm:ss"];

    [format setTimeZone:[NSTimeZone systemTimeZone]];

    NSLog(@"%@",[format stringFromDate:[NSDate date]]);

    

    NSCalendar *calendar1 = [NSCalendar currentCalendar];

    [calendar1 setTimeZone:[NSTimeZone systemTimeZone]];

    NSLog(@"%ld",[calendar1 component:NSHourCalendarUnit fromDate:[NSDate date]]);

 

  NSDate *date = [NSDate date];

  NSTimeZone *zone = [NSTimeZone systemTimeZone];

  NSInteger interval = [zone secondsFromGMTForDate: date];

  NSDate *localeDate = [date  dateByAddingTimeInterval: interval];  

  NSLog(@"%@", localeDate);

日期,时区

原文:http://www.cnblogs.com/ldc529/p/4367716.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!