I´m trying to set the date/time using the ADB shell but the shell only returns the current time.
I´ve tried:
adb shell date -s YYYYMMDD.HHmmss
and unix time like:
adb shell date 1318349236
any ideas?
I´m trying to set the date/time using the ADB shell but the shell only returns the current time.
I´ve tried:
adb shell date -s YYYYMMDD.HHmmss
and unix time like:
adb shell date 1318349236
any ideas?
You have to put date value if you want to change it. "-s" changes SET format. Default SET format is "MMDDhhmm[[CC]YY][.ss]".
I successfully tested the following commands:
At first it gets the current date of your machine and set it on the android target. This approach should work on Linux/Mac/Cygwin.
Android 6.0 has a new date format:
And setting with
-s
no longer works. This is the updated set command:Example of the updated command:
(while inside an adb shell)
will result in:
Notice: The command will not be visible immediately on the device because it doesn't trigger any time change broadcast, But it will be visible within a minute.
To work around that, you can append this broadcast manually this way:
To call this with an
adb
command:To make this work on my Xperia S, I had to break the commands as follows:
Motive: my device had reverted to the beginning of Linux time, and I wasn't particularly worried with time, all I wanted was to set the correct date -- which, BTW I couldn't do through system settings because my custom MIUI ROM kept crashing...
To save storage space Android like many other embedded systems uses multi-call binaries to implement its basic command line tools like
date
.Android device may include either
toolbox
ortoybox
(or both) binary depending on the version. You can check which implementation of thedate
tool available on your device by runningtoolbox date
andtoybox date
commands. Then you can use the one which prints out the current date. For example for an Android 6.0+ device it might look like:To set date and time using
toolbox date
useYYYYMMDD.HHmmss
format:In case of
toybox date
useMMDDhhmm[[CC]YY][.ss]
format:On some devices like RTAndroid maybe it works too: