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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM