久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

NSTimeInterval 到 unix 時間戳

NSTimeInterval to unix timestamp(NSTimeInterval 到 unix 時間戳)
本文介紹了NSTimeInterval 到 unix 時間戳的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我從 CMMotionManager 獲取 CMDeviceMotion 對象.CMDeviceMotion 的屬性之一是時間戳,它表示為 NSTimeInterval (double).根據文檔,這允許亞毫秒"時間戳精度.

I'm getting CMDeviceMotion objects from CMMotionManager. One of the properties of the CMDeviceMotion is timestamp, which is expressed as a NSTimeInterval (double). This allows for "sub millisecond" timestamp precision, according to documentation.

[motionManager startDeviceMotionUpdatesToQueue:motionQueue withHandler:^(CMDeviceMotion *motion, NSError *error) { 
  NSLog(@"Sample: %d Timestamp: %f ",counter,  motion.timestamp);
}

不幸的是,NSTimeInterval 是自上次設備啟動后計算的,這給以原始形式使用它帶來了重大挑戰.

Unfortunately, NSTimeInterval is calculated since last device boot, posing significant challenges to using it in its raw form.

有沒有人有工作代碼可以將此 NSTimeInterval 轉換為類似 Unix 的時間戳(UTC 時區)?

Does anyone have a working code to convert this NSTimeInterval into a Unix like timestamp (UTC timezone)?

謝謝!

推薦答案

在將磁力計值與 CoreMotion 事件進行比較時,我遇到了類似的問題.如果你想轉換這些 NSTimeIntervals 你只需要計算一次偏移量:

I had a similar problem when comparing magnetometer values with CoreMotion events. If you want to transform these NSTimeIntervals you just need to calculate the offset once:

// during initialisation

// Get NSTimeInterval of uptime i.e. the delta: now - bootTime
NSTimeInterval uptime = [NSProcessInfo processInfo].systemUptime;

// Now since 1970
NSTimeInterval nowTimeIntervalSince1970 = [[NSDate date] timeIntervalSince1970];

// Voila our offset
self.offset = nowTimeIntervalSince1970 - uptime;

這篇關于NSTimeInterval 到 unix 時間戳的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運行時,使用 iOS 6.0 SDK 并為 iOS 5 Target 構建會導致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
UIImageView zoom and pinch in UIScrollView(UIImageView 在 UIScrollView 中縮放和捏合)
主站蜘蛛池模板: 人操人人干人 | 日韩一级欧美一级 | av黄色在线观看 | 色婷婷亚洲国产女人的天堂 | 欧洲精品在线观看 | 国产黄a一级| 成人免费在线播放视频 | 亚洲精品视频在线播放 | 成人免费黄色片 | 日韩在线看片 | 三级免费 | 在线视频亚洲 | 黄色大片视频 | 午夜免费观看 | 性做久久久久久免费观看欧美 | 欧美精品一区二区三区蜜桃视频 | 国产一二三区在线 | 国产精品免费一区二区三区 | 伊人狠狠操 | 久久国产精品久久久久久久久久 | 欧美日韩综合一区 | 国产小视频在线 | 成年男女免费视频网站 | 日本一区二区三区精品视频 | 欧美一区二区三区视频 | 久久这里只有精品首页 | 久久久久国产一级毛片高清网站 | 国内精品在线视频 | 黑人性hd| 精品国产欧美 | 成人精品鲁一区一区二区 | 成人免费一级 | 久久一区二区三区四区 | 在线亚洲免费视频 | 日本黄色高清视频 | 国产三级日本三级 | 日本aⅴ中文字幕 | 欧美激情欧美激情在线五月 | 91视频在线看 | 欧美日韩在线免费 | 日本福利片 |