命令获取时间(以毫秒为单位)

问题描述:

Linux中是否有shell命令来获取以毫秒为单位的时间?

Is there a shell command in Linux to get the time in milliseconds?

date +%s%N返回秒数+当前纳秒.

date +%s%N returns the number of seconds + current nanoseconds.

因此,echo $(($(date +%s%N)/1000000))是您所需要的.

示例:

$ echo $(($(date +%s%N)/1000000))
1535546718115

date +%s返回自纪元以来的秒数,如果有用的话.

date +%s returns the number of seconds since the epoch, if that's useful.