thanks, sorry if it's not clear
I'm just trying to modify a time so its correct for a different timezone . .


so firstly I change the timezone environment variable

$ENV{TZ} = 'EST5EDT';

 # then i use the time&date i want changed in timelocal function

my $epochtime = timelocal($dbsec, $dbmin, $dbhour, $dbday, $dbmonth,$dbyear)

 # or to give you the actual values
my $epochtime = timelocal(00, 00, 21, 3, 03, 2003)

 # i.e. the time and date 21:00:00 March 3rd 2003
 # $epochtime for this is 1049425200

 # i pass this to localtime and format it

my $tm = localtime ($epochtime);
printf("<br>Date of epochtime prog: %02d:%02d:%02d - %02d/%02d/%02d\n",
    $tm->hour, $tm->min, $tm->sec,
    $tm->mday,$tm->mon+1,$tm->year+1900);

 # it comes out like this 
21:00:00 - 03/04/2003

it hasn't been changed

















complete script;

#!/usr/bin/perl

use CGI;
use strict;
use Time::Local 'timelocal_nocheck';
use Time::localtime;

$ENV{TZ} = 'EST5EDT';

my $epochtime = timelocal(00, 00, 21, 3, 03, 2003)
my $tm = localtime ($epochtime);
printf("<br>Date of epochtime prog: %02d:%02d:%02d - %02d/%02d/%02d\n",
    $tm->hour, $tm->min, $tm->sec,
    $tm->mday,$tm->mon+1,$tm->year+1900);

-----Original Message-----
From: $Bill Luebkert [mailto:[EMAIL PROTECTED]
Sent: 12 March 2003 16:19
To: Byrne, Dermot
Cc: [EMAIL PROTECTED]
Subject: Re: [Perl-unix-users] changing time from database to CET?


Byrne, Dermot wrote:
> thanks to everyone for their help on this . .
> I've nearly got it!
> 
> the timezone change works but only when I use current time
> 
> $ENV{TZ} = ":/usr/share/zoneinfo/America/New_York";
> 
> my $epochtime = timelocal($dbsec, $dbmin, $dbhour, $dbday, $dbmonth,
> $dbyear); # values out of database
> 
>              my $tm = localtime (time); # when used produces correct time
> i.e. five hours behind London
>              my $tm = localtime ($epochtime); # when used produces same
hour
> as $dbhour above i.e. doesn't change to timezone
> 
> 
> printf("<br>Date And Time Formatted: %02d:%02d:%02d - %02d/%02d/%02d\n",
>     $tm->hour, $tm->min, $tm->sec,
>     $tm->mday,$tm->mon+1,$tm->year+1900);
> 
> Could it be the typeof variable that $epochtime is?

epoch time is just an unsigned 32-bit integer (seconds since 1/1/1970).

> I've even tried lc($epochtime) before putting into localtime() function,
> in case it didn't realise it was a string!!

It's not a string.

> any further thoughts appreciated,

Try creating a test case that has all the data defined so we can actually
run it.  You're mixing and matching all kinds of junk in there and it's
hard to follow what your problem is.  You could also try setting TZ to
        $ENV{TZ} = 'EST5EDT';
and see if that makes any difference - although I don't even know what your
problem is from your description.

-- 
   ,-/-  __      _  _         $Bill Luebkert   ICQ=162126130
  (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic
http://www.todbe.com/


_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


http://www.musicchoice.co.uk

Support Digital Media - Join EDiMA - http://www.edima.org

Music Choice Limited (company registration number 2838971) is a
company incorporated in England and Wales with its registered
office at Fleet House, 57-61 Clerkenwell Road, London EC1M 5LA.
 
**********************************************************************
Information in this email is confidential and may be privileged. It is
intended for the addressee only. If you have received it in error,
please notify the sender immediately and delete it from your system.
You should not otherwise copy it, retransmit it or use or disclose its
contents to anyone.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to