Perl Notes/epoch.pl
From Federal Burro of Information
Jump to navigationJump to search
use Time::Local; my %month = ( 'Jan' => '0', 'Feb' => '1', 'Mar' => '2', 'Apr' => '3', 'May' => '4', 'Jun' => '5', 'Jul' => '6', 'Aug' => '7', 'Sep' => '8', 'Oct' => '9', 'Nov' => '10', 'Dec' => '11' ); my $year = "2013"; my $mon = 'Jan'; my $day = '10'; my $hour = '4'; my $min = '18'; my $sec = ''; $epoch = timelocal($sec,$min,$hour,$day,$month{$mon},$year); print "Epoch $epoch Time ".localtime($epoch)."\n";