current=`date "+%Y-%m-%d %H:%M:%S"` #获取当前时间,例:2016-06-06 15:40:41
timeStamp=`date -d "$current" +%s` #将current转换为时间戳,精确到秒
currentTimeStamp=$((timeStamp*1000+`date "+%N"`/1000000)) #将current转换为时间戳,精确到毫秒
echo $currentTimeStamp
http://ju.outofmemory.cn/entry/263908
方法二:
$[$(date +%s%N)/1000000]
博客介绍了在Shell脚本中获取精确到毫秒的时间戳的方法。一是先获取当前时间,再将其转换为精确到秒的时间戳,最后转换为精确到毫秒的时间戳;二是使用 $[$(date +%s%N)/1000000] 这种更简洁的方式。

被折叠的 条评论
为什么被折叠?



