Set date/time using ADB shell

后端 未结 11 2434
野趣味
野趣味 2020-12-04 15:59

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
         


        
11条回答
  •  一生所求
    2020-12-04 16:13

    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.

提交回复
热议问题