How to get current Unix time in seconds/milliseconds in Ubuntu/Arch Linux

This:

date +%s 

will return the number of seconds since the epoch.

This:

date +%s%N

returns the seconds and current nanoseconds.

This:

date +%s%3N

returns the seconds and current milliseconds.

If you want to convert back use following command

date -d @1501513250

or you can format timestamp via formater

date -d @1501513250 +'%Y-%m-%d %H:%M:%S'
comments powered by Disqus