Time in milliseconds since epoch in the terminal How do I get the time since the epoch, in milliseconds, in the OSX terminal?

The Linux/Ubuntu equivalent is date +%s.%N:

Linux $ date +%s.%N
1403377762.035521859


Which does not work in my OSX terminal:

OSX $ date +%s.%N
1403377800.N
The date program in OS X is different than GNU's coreutils date program. You can install coreutils (including gnu-date), then you will have a version of date that supports milliseconds.

As the installation from source can be a hassle for native OS X users I advise you to use Homebrew.

To install these tools using Homebrew run this oneliner in your terminal:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


Homebrew is now installed (it is wise to follow the installer's suggestions after installation). Now we will install coreutils using brew.

brew install coreutils


As the installation says, all commands have been installed with the prefix 'g' (e.g. gdate, gcat, gln, etc etc). If you really need to use these commands with their normal names, you can add a "gnubin" directory to your PATH (~/.bash_profile) like:

PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"


You can now run

gdate +%s.%N


and this will output your time since the epoch in milliseconds.