我正在寻找一种可以将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
感谢你帮我
发布于 2011-07-27 23:30:43
如果您只想要整数部分,则将双精度数转换为int:
NSNumber *timeStampObj = [NSNumber numberWithInt: (int)timeStamp];https://stackoverflow.com/questions/6845055
复制相似问题