http://qs321.pair.com?node_id=102262


in reply to Convert epoch seconds to date

How about this subroutine. I'm new to Perl, but think this works OK?:

sub unix_to_date { my ($date) = $_[0]; # reads in variable passed to subroutine my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug sep Oct Nov Dec!; #c +reates array of month names @time = (localtime($date))[3,4,5]; #creates array of date from unix ti +me $time[2] += 1900; # converts year to proper format return "$time[0]-$months[$time[1]]-$time[2]"; }

You now call this with:

$date_from_unix = &unix_to_date(epochtime);