NSGregorianCalendar 到 NSCalendar
我正在寻找一种可以将 NSGregorianCalendar 转换为时间戳的技术/方法。我可以制作双时间戳,但不能制作整数时间戳
这是我的代码:
//Create the timestamp of the date
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
// NSTimeInterval is defined as double
NSNumber *timeStampObj = [NSNumber numberWithDouble: timeStamp];
NSLog(@"%@", timeStampObj);
但它给了我类型为 1311780128.540395 的时间戳,我只想要 1311780128
感谢帮助我
I'm searching for a technique/method that can transform NSGregorianCalendar into a timestamp. I can make a double timestamp but not a integer timestamp
Here's my code:
//Create the timestamp of the date
NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
// NSTimeInterval is defined as double
NSNumber *timeStampObj = [NSNumber numberWithDouble: timeStamp];
NSLog(@"%@", timeStampObj);
But it gives me a timestamp of the type 1311780128.540395 And I want just 1311780128
Thanks to help me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只想要整数部分,请将 double 转换为 int:
If you just want the integer portion, cast the double to an int: