Is this possible to get Last shutdown or reboot time using objective c or Swift.
I tried many websites and forums. i can't find solution for this problem.
Is this possible to get Last shutdown or reboot time using objective c or Swift.
I tried many websites and forums. i can't find solution for this problem.
Check out NSProcessInfo there is a property called systemUptime of type NSTimeInterval
NSProcessInfo.processInfo().systemUptime
[[NSProcessInfo processInfo] systemUptime]
I gave you your answer in both objective-c and swift since you tagged them both.
You cannot detect the last shutdown time. But you can detect the last reboot time as:
let systemUptime = NSProcessInfo.processInfo().systemUptime;
And to detect the time, since last reboot is:
let systemUptime = NSProcessInfo.processInfo().systemUptime;
let timeNow = NSDate().timeIntervalSince1970
let dateOfLastReboot = NSDate(timeIntervalSince1970: timeNow-systemUptime)