Saturday, January 8, 2022

[SOLVED] Command to get time in milliseconds

Issue

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


Solution

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

Therefore, echo $(($(date +%s%N)/1000000)) is what you need.

Example:

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

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



Answered By - Alper