日期怎么会转换成错误的时间?
result=$(ls /path/to/file/File.*)
#/path/to/file/File.1361234760790
currentIndexTime=${result##*.}
echo "$currentIndexTime"
#1361234760790
date -d@"$currentIndexTime"
#Tue 24 Oct 45105 10:53:10 PM GMT
最佳答案
这个特定的时间戳是自纪元以来的毫秒数,而不是自纪元以来的标准秒数。除以 1000:
$ date -d @1361234760.790
Mon Feb 18 17:46:00 MST 2013
关于Bash 将纪元转换为日期,显示错误的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16311688/