Search code examples
perlepochlocaltime

Perl epoch time before 1970 formatting


I have problem formatting and dealing with dates before the epoch 1/1/1970 in Perl, dates comes back as negative integer:

my $time=timelocal(0, 0, 0, 1, 1, 1969);
print "$time\n"; 
$theTime = localtime($time); 
print "the time is good: $theTime\n\n";

How to deal with dates before the epoch in Perl, both on unix and windows have the same problem Perl 5.8.8. PHP shows the date normal without problems.


Solution

  • have you tried using DateTime?