首页 > 其他 > 详细

NSDate && TimeStamp

时间:2016-03-04 10:26:06      阅读:156      评论:0      收藏:0      [点我收藏+]
// 1. NSDate to timeStamp
NSString *timeSp = [NSString stringWithFormat:@"%d", (long)[localeDate timeIntervalSince1970]];
// timeStamp
NSLog(@"timeSp:%@",timeSp);
 
// 2. 获取当前时间
NSDate *datenow = [NSDate date];
 
NSTimeZone *zone = [NSTimeZone systemTimeZone];
 
NSInteger interval = [zone secondsFromGMTForDate:datenow];
 
NSDate *localeDate = [datenow dateByAddingTimeInterval: interval];
 
NSLog(@"%@", localeDate);
 
 
 
// 3. timestamp to NSDate
NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:1363948516];
 
NSLog(@"1363948516 = %@",confromTimesp);

NSDate && TimeStamp

原文:http://www.cnblogs.com/wealon/p/5240997.html

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