码迷,mamicode.com
首页 > 其他好文 > 详细

NSDate && TimeStamp

时间:2016-03-04 10:26:51      阅读:166      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!