Archive

Posts Tagged ‘epoch time’

Epoch time date calculation

April 8th, 2009 No comments

In the Unix/Linux world we always come across at one point with the term “epoch time”. The epoch time is actually the number of seconds elapsed since midnight of January 1, 1970. Some application record the date and time in “epoch time”. Squid proxy server, for an example will record date and time entries in its log in epoch time.

I think we will all agree, that working with this kind of date format is not very meaningful for us. So, if you ever need to convert an epoch time format to a more readable format, here are some example using the bash shell.

Convert epoch time to date format

# date -d @1221256800 "+%Y-%m-%d %T"
 2008-09-13 00:00:00

Convert date to epoch time

# date -d "20080913" +%s"
 1221256800
Categories: Scripting