Andrew Spott
Andrew Spott

Reputation: 3627

In iOS, using Swift, how do you get the time of iPhone boot?

In core motion, data is returned in a class inheriting from CMLogItem, which has a timestamp property. The timestamp is a TimeInterval that is the time since the device booted.

How do I get when the device booted?

Upvotes: 3

Views: 1519

Answers (1)

Andrew Spott
Andrew Spott

Reputation: 3627

From the comments, I was able to find ProcessInfo.processInfo.systemUptime which is the time since last boot. From this, and Date(), I can get the time of start via:

time_of_last_boot = Date() - ProcessInfo.processInfo.systemUptime

Upvotes: 5

Related Questions