Set up android time (time zone) synchronization through adb shell

Set time synchronization and set the time zone to Shanghai

  1. Enter the adb shell environment. Open a terminal or command prompt on your computer and run the following command: adb shell

  2. Obtain root permissions (if the device is rooted). Run the following command in the adb shell environment: su

  3. Enable automatic time synchronization and automatic time zone synchronization. Run the following commands to enable automatic time and automatic time zone synchronization for your device:

    1. settings put global auto_time 1

    2. settings put global auto_time_zone 1

  4. Set the time zone of the device. Run the following command to set the device's time zone. Replace  <timezone> with the desired time zone value, for example "Asia/Shanghai" :

    1. setprop persist.sys.timezone <timezone>

  5. Exit the adb shell environment. Run the following command in the adb shell environment: exit

If you want to set a specific time

  1. Enter the adb shell environment. Open a terminal or command prompt on your computer and run the following command: adb shell

  2. Obtain root permissions (if the device is rooted). Run the following command in the adb shell environment: su

  3. Set device time. Use the date command to set the date and time of the device. Here are some example commands:

    • Set date and time: Set the date and time in the format of "YYYY-MM-DD HH:MM".

      date -s "2022-12-31 23:59"
      
    • Set date: Set the date in the format of "YYYY-MM-DD".

      date -s "2022-12-31"
      
    • Set time: Set the time in the format of “HH:MM”.

      date -s "23:59"
      
  4. Exit the adb shell environment. Run the following command in the adb shell environment: exit

Note: Android devices will now automatically synchronize time with network time servers and automatically update the time zone based on the set time zone. The device will automatically update using time and time zone information provided by the network. Please make sure the device is connected to the Internet for time synchronization and time zone updates.

Guess you like

Origin blog.csdn.net/xch622114/article/details/132337017