in reply to Error from timelocal

I would recommend reading merlyn's Getting a date with Perl.

There's quite a bit of general information there and who knows - it may even solve your problem!

Replies are listed 'Best First'.
How disappointing
by logan (Curate) on Dec 20, 2002 at 21:48 UTC
    "Getting a date with Perl" may be the most misleading title since "Naked Lunch". It's Friday night, and despite (or because of) my skill with Perl, I still have the same problem as before: no date. If Perl could help people get dates, C would be deader than Pascal and Larry Wall would be richer than Bill Gates.

    -Logan
    "What do I want? I'm an Perl Coder. I want more dates."

      From my reading of the problem, mkent simply has a problem translating the variables in his file with Time::Local.

      Reproducing merlyn's article we get:

      #!/usr/bin/perl -w use strict; use CGI ':standard'; use Time::Local; my $time = timelocal(0,0,0,1,0,100); my $string = localtime $time; print header(), start_html(-title => ""); print "the big ball falls at $time => $string\n"; print end_html();
      Simply placing the mkent's line:
      my $time = timelocal($sec,$min,$hhour,$day,$month,$year);
      should work in the same way provided MarkM's advice is followed:
      my $time = timelocal($sec,$min,$hhour,$day,$month-1,$year-=1900);
      So finally we have:
      #!/usr/bin/perl -w use strict; use CGI ':standard'; use Time::Local; my $sec = "50"; my $min = "20"; my $hhour = "10"; my $day = "12"; my $month = "12"; my $year = "2002"; my $time = timelocal($sec,$min,$hhour,$day,$month-1,$year-=190 +0); my $string = localtime $time; print header(), start_html(-title => ""); print "the big ball falls at $time => $string\n"; print end_html();
      The truth is in there. Somewhere.
Re: Re: Error from timelocal
by mkent (Acolyte) on Dec 28, 2002 at 20:33 UTC
    Thanks. This was good reading, though I still have the problem!
      Did you run merlyn's script with your parameters? In the script I showed it worked well so you would need to post more code and data to see where the problem might be.

      The truth is in there. Somewhere...