Convert Unix timestamp to a readable date in Perl
问题 I have some Unix timestamps (for example, 1357810480, so they're mainly in the past). How can I transform them into a readable date-format using Perl? 回答1: You can use localtime for that. my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($unix_timestamp); 回答2: Quick shell one-liner: perl -le 'print scalar localtime 1357810480;' Thu Jan 10 10:34:40 2013 Or, if you happen to have the timestamps in a file, one per line: perl -lne 'print scalar localtime $_;'