in reply to Re^2: Date Timezone
in thread Date Timezone

Please show us a full Short, Self-Contained Correct Example. A full blown script as small as possible that fully shows the problem. What you've shown will just lead to endless guessing. For example, you don't even show us in the etc... where you're actually calling the sub... are you? Also, you don't need (and unless you know when you should) shouldn't be using prototypes in your sub definition (ie. remove the ()).

Do you have use strict; and use warnings;? huck may be onto something. You are not scoping the return variable within the sub (if it's not declared globally, strict will catch that).

Replies are listed 'Best First'.
Re^4: Date Timezone
by kepler (Scribe) on Jul 16, 2017 at 01:29 UTC

    Hi

    Thanks for the help, but I only found one solution: to put the following inside the function:
    my $dt = DateTime->new( year => $my_year, month => $my_mon, day => $my_day, hour => $my_hours, minute => $my_minutes, time_zone => 'GMT', ); $dt->set_time_zone( $zone ); $rh = $dt->hour; #returns the adjusted hour $rm = $dt->minute; #returns the adjusted minutes
    $zone must be declared 'local' outside the procedure. We can play actually with 2 timezones (not putting GMT but $zone2 for example). Regards. Kepler