1.  首页
  2.  博客
  3. iOS NSDate 与 timestamp 转换

iOS NSDate 与 timestamp 转换


NSDate *now = [NSDate date];
NSTimeInterval interval = [now timeIntervalSince1970];
NSLog(@"%@", now);   // Date
NSLog(@"%f", interval);    // Date to Timesatmp
NSLog(@"%@", [NSDate dateWithTimeIntervalSince1970:interval]); // Timestamp to Date

评论 0