常用shell(1):shell获取系统当前时间戳

来源:互联网 发布:淘宝卖店铺 编辑:程序博客网 时间:2024/06/13 08:35

1. shell脚本如下

current=`date "+%Y-%m-%d %H:%M:%S"`  timeStamp=`date -d "$current" +%s`   #将current转换为时间戳,精确到毫秒  currentTimeStamp=$((timeStamp*1000+`date "+%N"`/1000000)) echo $currentTimeStamp

2. 运行效果

这里写图片描述

原创粉丝点击