shell脚本获取时间戳代码

#明天凌晨 对应的毫秒时间戳

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

#当前时间 对应的毫秒时间戳

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

#当前时间 对应的秒时间戳

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

 

版权声明:
作者:WaterBear
链接:https://l-t.top/2161.html
来源:雷霆运维
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>
文章目录
关闭
目 录