This little Perl one-liner can get handy when you need to translate “time in seconds since the Epoch” (for example in logs) to local time :
% perl -e 'print scalar(localtime(1202484725)), "\n";'
Fri Feb 8 16:32:05 2008
This was pretty useful today when browsing through Nagios event logs, where times are given in seconds from the Epoch.
By the way, the Epoch is defined as 00:00 UTC on January, 1st, 1970.
3 thoughts on “Perl : Convert time from Epoch to local time”
Thanks again, you’re the “one-liner master” !
On Windows you have to swap the quotes
perl -e “print scalar(localtime(1202484725)), ‘\n’;”
very helpful command
Comments are closed.