Set date/time using ADB shell

2019-01-14 03:30发布

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?

标签: android adb
8条回答
Evening l夕情丶
2楼-- · 2019-01-14 04:11

The correct format that has worked for me is yyyyMMddHHmm.ss

查看更多
小情绪 Triste *
3楼-- · 2019-01-14 04:12

Expanding on @uval's answer, you can use the following to update the date and time on the android device based on the time on your Windows machine:

set dateYYYY=%date:~10,4%
set dateMM=%date:~4,2%
set dateDD=%date:~7,2%
set timeHH=%time:~0,2%
set timeMM=%time:~3,2%
set timeSS=%time:~6,2%

adb shell su -c date %dateMM%%dateDD%%timeHH%%timeMM%%dateYYYY%.%timeSS%
adb shell su -c am broadcast -a android.intent.action.TIME_SET

Tested on a rooted Android 6.0 device and a Windows 10 PC.

查看更多
登录 后发表回答