date

简介

打印或者设置系统时间

选项

  • -d 通过字符串来描述时间
  • -f 从文件中读取字符串来描述时间
  • -r 打印文件的最后修改时间
  • -R 以rfc2822规范来显示时间
  • –rfc-3339 以rfc3339来显示,可用date,seconds和ns
  • -s 设置时间
  • -u 打印utc时间
  • +format 格式化时间,常用的有%D,%F,%n,%s

示例

显示时间戳:

date +%s

显示标准日期格式:

date +%F