Set date/time using ADB shell

后端 未结 11 2432
野趣味
野趣味 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:15

    Android 6.0 has a new date format:

    Default SET format is "MMDDhhmm[[CC]YY][.ss]", that's (2 digits each)
    month, day, hour (0-23), and minute. Optionally century, year, and second.
    

    And setting with -s no longer works. This is the updated set command:

    Example of the updated command:

    (while inside an adb shell)

    date 060910002016.00                              
    

    will result in:

    Thu Jun  9 10:00:00 GMT 2016
    

    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:

    date 060910002016.00 ; am broadcast -a android.intent.action.TIME_SET
    

    To call this with an adb command:

    adb shell 'date 060910002016.00 ; am broadcast -a android.intent.action.TIME_SET'
    

提交回复
热议问题