Is there a shell command in Linux to get the time in milliseconds?
Unix Time in Milliseconds Another option is to represent timestamps using the number of milliseconds since the Unix epoch instead of the number of seconds.
Time Command Versions To use the Gnu time command, you need to specify the full path to the time binary, usually /usr/bin/time , use the env command or use a leading backslash \time which prevents both and built-ins from being used.
date +"%T.%N"
returns the current time with nanoseconds.
06:46:41.431857000
date +"%T.%6N"
returns the current time with nanoseconds rounded to the first 6 digits, which is microseconds.
06:47:07.183172
date +"%T.%3N"
returns the current time with nanoseconds rounded to the first 3 digits, which is milliseconds.
06:47:42.773
In general, every field of the date
command's format can be given an optional field width.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With