How long device has been running since last charge? In Android Lollipop, how do I see how long it has been since the last time I charged the battery? I mean I can get the approximate time by eye-balling the graph shown in Settings -> Battery. But, is it possible to get a precise time period like: "your device has been running x hours y minutes since last charge".

Or any app that can give me this info? All battery apps seem to concentrate on telling me how much longer the device can last from now. No history info.

Note: I'm not asking about the up time :-)
From a root terminal on your device:

dumpsys batterystats | grep "Start clock time"


That will give the date/time of when the device was last disconnected from the charger (while fully charged), rather than the time since, but comparing to the current date and time is easy enough.

I did come up with a more complicated command you could save to a script to yield a 1d 2h 3m style format:

busybox expr $(date +%s) - $(dumpsys batterystats --checkin | grep "l,bt" | busybox awk -F',' '{printf "%i", $10/1000}') | busybox awk '{printf "%id %ih %im\n", $1/60/60/24, $1/60/60 % 24, $1/60 % 60}'


To explain that:


Get the batterystats line that includes the milliseconds-since-the-epoch time of the last charger disconnection
Use awk to strip out that time and convert it to seconds
Subtract it from the current time to get the interval in seconds
Use awk to format it