View Full Version : Help with fixing date problem in CGI/Perl

18-04-2002, 03:15 AM
Here's the script:

sub get_date {
@days = ('Sunday','Monday','Tuesday','Wednesday',
@months = ('January','February','March','April','May','June' ,'July',
'August','September','October','November','Decembe r');
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf('%02d:%02d:%02d',$hour + 16,$min,$sec);
$year += 1900;
$date = '$days[$wday], $months[$mon] $mday, $year at $time';

I have added + 16 to the hours because this is how much the server is off by but this didn't work quite as intended as it now displays times above 24 hours.

I have no experience in CGI/Perl and have found no information regarding this. Is there a way to say if hours is greater than 24 then minus 24 and add one day? Don't know if that will work but if there's a way to do it could you please help me out.

Doc Flash