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 root
adb remount
adb shell date "2023-01-11 18:00:00"
adb shell "date 01111800.00"
# 1月11号 下午6点/18点 :日落
adb root
adb remount
adb shell date "2023-01-11 07:00:00"
adb shell "date 01110700.00"
# 1月11号 上午7点 : 日出
adb root
adb remount
adb shell date "2023-01-11 08:00:00"
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 shell
su
date -s "2024-04-16 18:00:00"

早上八点:
adb shell
su
date -s "2024-04-16 08:00:00"

中午十二点:
adb shell
su
date -s "2024-04-16 12:00:00"

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值