iOS中对时间的处理(一)——获取当前时间戳

来源:互联网 发布:耽美网络剧资源 编辑:程序博客网 时间:2024/06/05 14:33


    NSDate *da = [NSDatedateWithTimeIntervalSinceNow:0];

    NSTimeInterval ti = [datimeIntervalSince1970]*1000;

   NSString *timeStr = [NSStringstringWithFormat:@"%.0f",ti];  // 转为字符型

   NSLog(@"time__%@",timeStr);


输出:[Line 566] time__1433990782653


如果不乘以1000

输出:[Line 566] time__1433990304


// 乘以1000是为了精确到毫秒,不乘以1000是精确到秒

0 0
原创粉丝点击