How do I get the current Unix time in milliseconds (i.e number of milliseconds since Unix epoch January 1 1970)?
Bash – How to get the current Unix time in milliseconds in Bash
bashtimeunix
bashtimeunix
How do I get the current Unix time in milliseconds (i.e number of milliseconds since Unix epoch January 1 1970)?
Best Answer
This:
will return the number of seconds since the epoch.
This:
returns the seconds and current nanoseconds.
So:
will give you the number of milliseconds since the epoch - current seconds plus the left three of the nanoseconds.
and from MikeyB -
echo $(($(date +%s%N)/1000000))
(dividing by 1000 only brings to microseconds)