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

I'm using the following to get GMT, but I really need $dateadded to be Hawaii time which I believe is GMT - 10 hours. How can I do this?
@months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun); ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWee +k, $dayOfYear, $daylightSavings) = gmtime(); $year = 1900 + $yearOffset; $dateadded = "$weekDays[$dayOfWeek] $months[$month] $dayOfMonth, $yea +r - $hour:$minute:$second";
Thanks.

Replies are listed 'Best First'.
Re: Getting a specific time zone
by ikegami (Patriarch) on Jul 08, 2010 at 06:47 UTC
    use DateTime qw( ); my $dt = DateTime->now( time_zone => 'Pacific/Honolulu' ); my $date_added = $dt->strftime("%a %b %e, %Y - %k:%M:%S");
Re: Getting a specific time zone
by Ratazong (Monsignor) on Jul 08, 2010 at 06:44 UTC

    Have you tried Date::Calc? Knowing that Hawaii is 10 hours behind, you can use the function Add_Delta_YMDHMS() to subtract those hours from your gmtime()-result.

    HTH, Rata