Search code examples
linuxbashdatetimetimestampunix-timestamp

How to get the current time in seconds since the epoch, in Bash on Linux?


I need something simple like date, but in seconds since 1970 instead of the current date, hours, minutes, and seconds.

date doesn't seem to offer that option. Is there an easy way?


Solution

  • This should work:

    date +%s
    

    As recently corrected in the date manual:

    %s = seconds since the Epoch (1970-01-01 00:00 UTC)