Get Current date in epoch from Unix shell script

Krishna picture Krishna · Jul 7, 2009 · Viewed 121.6k times · Source

How to get the current date value in epoch i.e., number of days elapsed since 1970-1-1. I need solution in unix shell script.

Answer

UberAlex picture UberAlex · Jul 7, 2009

The Unix Date command will display in epoch time

the command is

date +"%s"

https://linux.die.net/man/1/date

Edit: Some people have observed you asked for days, so it's the result of that command divided by 86,400