#!/usr/bin/perl
use strict;
use warnings;
use Time::Local;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
$mday = 13;
$mon = 9; # 0 - 11, so this is October
$year = 1973;
# use 12pm
my $seconds = timelocal(0,0,12,$mday,$mon,$year);
print "epoch seconds: $seconds.\n";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($sec
+onds);
$year += 1900;
$mon++;
printf "%02d:%02d:%02d %04d-%02d-%02d\n", ($hour,$min,$sec,$year,$mon,
+$mday);
update: You could also use the Date_to_Time and Time_to_Date functions of Date::Calc.
#!/usr/bin/perl
use strict;
use warnings;
use Date::Calc qw(:all);
my ($sec,$min,$hour,$day,$month,$year, $seconds);
$sec = 0;
$min = 0;
$hour = 12;
$day = 13;
$month = 10;
$year = 1973;
$seconds = 0;
# use 12pm
$seconds = Date_to_Time($year,$month,$day, $hour,$min,$sec);
print "epoch seconds: $seconds.\n";
($year,$month,$day, $hour,$min,$sec) = Time_to_Date($seconds);
printf "%02d:%02d:%02d %04d-%02d-%02d\n", ($hour,$min,$sec,$year,$mont
+h,$day);
|