This plugin will return the device uptime that is not affected by changing the device date/time settings.
If you are using cordova-cli, install with:
cordova plugin add cordova-plugin-uptime
With a plain plugman, you should be able to install with something like:
plugman --platform <ios|android> --project <directory> --plugin https://github.com/MartinDomig/cordova-plugin-uptime.git
The value returned is a string data type. In JavaScript, you might want to convert it to integer before using it for calculations.
cordova.getUptime(function (uptime) {
console.log("uptime in milliseconds: " + parseInt(uptime));
});
- Android
- iOS
- Browser
- The return value is a string data type. This is because there is, as far as I know, no way to return a long value from an android cordova plugin. Please let me know if you know better.
- Browser support is not system time independent. It doesn't return system uptime, but the time since the browser loaded the application.
## Credits
Written by Martin Domig