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
or toybox
(or both) binary depending on the version. You can check which implementation of the date
tool available on your device by running toolbox date
and toybox 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:
$ adb shell toybox date
Mon Jul 31 21:09:28 CDT 2017
$ adb shell toolbox date
date: no such tool
To set date and time using toolbox date
use YYYYMMDD.HHmmss
format:
adb shell "su 0 toolbox date -s 20161231.235959"
In case of toybox date
use MMDDhhmm[[CC]YY][.ss]
format:
adb shell "su 0 toybox date 123123592016.59"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…