adb shell date 修改系统时间和时区

adb shell date帮助

adb shell date --help
usage: date [-u] [-r FILE] [-d DATE] [+DISPLAY_FORMAT] [-D SET_FORMAT] [SET]

Set/get the current date/time. With no SET shows the current date.

-d      Show DATE instead of current time (convert date format)
-D      +FORMAT for SET or -d (instead of MMDDhhmm[[CC]YY][.ss])
-r      Use modification time of FILE instead of current date
-u      Use UTC instead of current timezone

Supported input formats:

MMDDhhmm[[CC]YY][.ss]     POSIX
@UNIXTIME[.FRACTION]      seconds since midnight 1970-01-01
YYYY-MM-DD [hh:mm[:ss]]   ISO 8601
hh:mm[:ss]                24-hour time today

All input formats can be preceded by TZ="id" to set the input time zone
separately from the output time zone. Otherwise $TZ sets both.

+FORMAT specifies display format string using strftime(3) syntax:

%% literal %             %n newline              %t tab
%S seconds (00-60)       %M minute (00-59)       %m month (01-12)
%H hour (0-23)           %I hour (01-12)         %p AM/PM
%y short year (00-99)    %Y year                 %C century
%a short weekday name    %A weekday name         %u day of week (1-7, 1=mon)
%b short month name      %B month name           %Z timezone name
%j day of year (001-366) %d day of month (01-31) %e day of month ( 1-31)
%N nanosec (output only)

%U Week of year (0-53 start sunday)   %W Week of year (0-53 start monday)
%V Week of year (1-53 start monday, week < 4 days not part of this year)

%F "%Y-%m-%d"     %R "%H:%M"        %T "%H:%M:%S"    %z numeric timezone
%D "%m/%d/%y"     %r "%I:%M:%S %p"  %h "%b"          %s unix epoch time
%x locale date    %X locale time    %c locale date/time

1、设置时间

adb shell "date 01111800.00"
# 1月11号 下午6点

adb shell "date 01110800.00"
# 1月11号 上午8点

2、读取时间

adb shell "date"
Tue Jan 11 00:01:53 CST 2022

3、设置时区

adb shell "setprop persist.sys.timezone Pacific/Midway"

Pacific/Midway为设置的时区

4、读取时区

adb shell "getprop persist.sys.timezone"
Asia/Shanghai

你可能感兴趣的:(工具,adb)