PERL coding issue with dates

Discussion in 'CGI/Perl/Python' started by smoniz, Apr 9, 2007.

  1. smoniz

    smoniz New Member

    Hello all

    I downloaded a newsboard script and it works just fine except the date, it seems to want to put the day one day ahead of what it actually is and the time is completely off

    For example Newsboard Headline April 10th2007 14:00

    When it is actually april 9th and it is 11:00am. Here is the function i found in the script, any one have any ideas?


    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

    $month = ($mon + 1);

    @months = ("January","February","March","April","May","June","July","August","September","October","November","December");

    $year += 1900;
    $long_date = sprintf("%s %02d, %4d at %02d:%02d:%02d",$months[$mon],$mday,$year,$hour,$min,$sec);

    $year %= 100;
    if ($use_time == 1) {
    $date = sprintf("%02d:%02d:%02d %02d/%02d/%02d",$hour,$min,$sec,$month,$mday,$year);
    }
    else {
    $date = sprintf("%02d/%02d/%02d",$month,$mday,$year);
    }
    }

Share This Page