我检索 NSTimeInterval 如下:
NSTimeInterval milisecondedDate = ([[NSDate date] timeIntervalSince1970] * 1000);
记录以下内容: UNIX时间戳:“1307710190993.865967”
我只希望点之前的值与 JSON 一起发送,如下所示:
"/日期(1307710131826+0200)/"
有什么建议么?
提前致谢,
我检索 NSTimeInterval 如下:
NSTimeInterval milisecondedDate = ([[NSDate date] timeIntervalSince1970] * 1000);
记录以下内容: UNIX时间戳:“1307710190993.865967”
我只希望点之前的值与 JSON 一起发送,如下所示:
"/日期(1307710131826+0200)/"
有什么建议么?
提前致谢,
获取自 1970 UNIX 时间戳以来的当前时间戳(以毫秒为单位)。
NSTimeInterval millisecondedDate = ([[NSDate date] timeIntervalSince1970] * 1000);
将毫秒数日期格式化为不带小数的字符串。
NSString* formattedMilliseconds = [NSString stringWithFormat:@"%.0f", millisecondedDate];
以 DateTime .net 格式设置时间戳。
NSString *startOfDateFormat = @"/Date(";
NSString *endOfDateFormat = @"+0200)/";
NSString *dateTimeNow = [NSString stringWithFormat:@"%@%@%@",startOfDateFormat, formattedMilliseconds, endOfDateFormat];
这样做可能有更好的解决方案,但目前这对我有用。