Converting from or to Unix timestamps
This article is very old (more than 13 years) and likely outdated. Please be careful and take everything in here with a grain of salt.
Unix timestamps (sometimes also called epoch) encode date and time in a single number, counting the seconds since January 1, 1970, 00:00 (UTC). The format is used througout a lot of software, but how can it be decoded to our common format?
Naturally, there are web services like Epoch Converter, but how to decode it using the common GNU command line tools? Here’s a short summary:
Epoch -> Human time:
date -d @1234567890
Human time -> Epoch:
date -d "2010-10-20 20:10" +%s
Current time (in human format and in epoch):
date
date +%s
Find out more about date formatting using
man date