43 字
1 分钟
命令行时间戳与时间转换
Linux
date -d @<timestamp>macOS / FreeBSD
date -r <timestamp>PowerShell
[datetime]::UnixEpoch.AddSeconds(<timestamp>)Zsh
strftime '%Y-%m-%d %H:%M:%S' <timestamp>Python
python3 -c "import sys, time; print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(sys.argv[1]))))" <timestamp>Perl
perl -MPOSIX -le 'print strftime "%Y-%m-%d %H:%M:%S", localtime($ARGV[0])' <timestamp>Ruby
ruby -e 'puts Time.at(ARGV[0].to_i).strftime("%Y-%m-%d %H:%M:%S")' <timestamp>Groovy
groovy -e "println new Date(args[0] as long).format('yyyy-MM-dd HH:mm:ss')" <timestamp>Node
node -e "console.log(new Date(parseInt(process.argv[1])).toLocaleString())" <timestamp>