Linux/macOS 如何进行时间戳转换?

时间戳转换网站

https://tool.lu/timestamp/

https://tool.lu/timestamp/

https://tool.chinaz.com/tools/unixtime.aspx
https://tool.chinaz.com/tools/unixtime.aspx

Linux 时间戳转日期时间

1
2
3
4
# date -d @timestamp
# date -d@timestamp
date -d @1574933006
date -d@1574933006

macOS 时间戳转日期时间

1
2
3
4
# date -r timestamp
# date -rtimestamp
date -r 1574933006
date -r1574933006

日期时间转时间戳

目前没有特别好用的方法,还是去网站上转吧

Linux 获取当前时间戳

1
date +%s

macOS 获取当前时间戳

1
date +%s