1. 程式人生 > >Shell 獲取系統當前時間戳

Shell 獲取系統當前時間戳

current=`date "+%Y-%m-%d %H:%M:%S"`  
timeStamp=`date -d "$current" +%s`   
#將current轉換為時間戳,精確到毫秒  
currentTimeStamp=$((timeStamp*1000+`date "+%N"`/1000000)) 
echo $currentTimeStamp