- 先察看支持什么格式
此处h是故意报错用的。
$ date -h
date: invalid option -- 'h'
BusyBox v1.31.1 (2023-04-25 18:55:34 PDT) multi-call binary.Usage: date [OPTIONS] [+FMT] [TIME]Display time (using +FMT), or set time[-s,--set] TIME Set time to TIME-u,--utc Work in UTC (don't convert to local time)-R,--rfc-2822 Output RFC-2822 compliant date string-I[SPEC] Output ISO-8601 compliant date stringSPEC='date' (default) for date only,'hours', 'minutes', or 'seconds' for date andtime to the indicated precision-r,--reference FILE Display last modification time of FILE-d,--date TIME Display TIME, not 'now'-D FMT Use FMT (strptime format) for -d TIME conversionRecognized TIME formats:hh:mm[:ss][YYYY.]MM.DD-hh:mm[:ss]YYYY-MM-DD hh:mm[:ss][[[[[YY]YY]MM]DD]hh]mm[.ss]'date TIME' form accepts MMDDhhmm[[YY]YY][.ss] instead
- 设置
选择YYYY-MM-DD hh:mm[:ss]
$ date -s "2024-02-05 11:18"
Mon Feb 5 11:18:00 UTC 2024
- 设置时区
LINUX查看、设置时区-CSDN博客