Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have a script which creates a printable version of html pages into black and white.

I have a header on the generated pages - this prints the generated date. For this I use:

$date = `/bin/date`;

However, the time is wrong (1 hour behind - I am in GMT).

I do not have access to the server to correct this but can FTP onto it.

I have read you can privatley set the time zone TZ within a script - does anyone know how I can do this to correct my time and date?

Replies are listed 'Best First'.
Re: Correcting Time
by blakem (Monsignor) on Sep 13, 2002 at 10:08 UTC
    How about:
    $date = localtime(time + 60*60);
    Update: WooHoo, my 1,000th node!

    -Blake

      Cheers for that! Worked a treat!

      :-) and congrats on your 1000th!
Re: Correcting Time
by joe++ (Friar) on Sep 13, 2002 at 12:08 UTC
    What about this:
    print scalar localtime(), "\n"; $ENV{TZ}="Europe/London"; print scalar localtime(), "\n";
    Prints the following for me (I'm in CET, that is Europe/Amsterdam):
    Fri Sep 13 13:51:50 2002 Fri Sep 13 12:51:50 2002
    Cheers,

    Joe.

Re: Correcting Time
by claree0 (Hermit) on Sep 13, 2002 at 10:19 UTC
    Are you sure you're one hour behind - given that 'local time' in the UK is currently GMT+1?
      Well ok, but the principle was still the same - the time was 1 displayed on the page was 1 hour behind.