首页 > 其他 > 详细

时间戳

时间:2015-05-24 12:44:52      阅读:155      评论:0      收藏:0      [点我收藏+]

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

    [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];   

//    1

    NSDate *date = [NSDate date];

    NSLog(@"时间  %@",[formatter stringFromDate:date]);      

    NSString *timeSp = [NSString stringWithFormat:@"%d", (long)[[formatter dateFromString:[formatter stringFromDate:date]] timeIntervalSince1970]];

    NSLog(@"---timeSP---- %@ ",timeSp);

//    2

    NSTimeInterval time=[timeSp doubleValue];

    NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time];

    NSLog(@"date:%@",[detaildate description]);    

    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:[timeSp doubleValue]];

    NSLog(@"1296035591  = %@",confromTimesp);

    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];

    NSLog(@"confromTimespStr =  %@",confromTimespStr);

时间戳

原文:http://www.cnblogs.com/lyl-/p/4525590.html

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