Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command to get time in milliseconds

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

like image 530
MOHAMED Avatar asked May 14 '13 16:05

MOHAMED


People also ask

Is Unix 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.

How do you use time command?

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.


1 Answers

  • 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.

like image 102
Michael Defort Avatar answered Sep 22 '22 06:09

Michael Defort