#!/usr/bin/perl -- use warnings; use strict; use DateTime; use DateTime::TimeZone; use DateTime::Format::MySQL; my @Tzs = ( 'America/Los_Angeles', 'UTC', 'America/New_York', ); my $somewhere_time = "2011-06-09 08:19:12"; # pacific time? my $dt = DateTime::Format::MySQL->parse_datetime($somewhere_time); print $dt->_TZLP; Tzss( $dt ); print ' ' x 21, DateTime::Format::MySQL->format_datetime($dt),"\n\n"; # I should be expecting to get: 2011-06-09 10:19:12 Tzss( DateTime->now ); sub Tzss { my $dt = shift; for my $tz ( @Tzs ) { $dt->set_time_zone( $tz ); print $dt->_TZLP; } } sub DateTime::_TZLP { sprintf "%-20s %s\n", $_[0]->time_zone_long_name, $_[0]->strftime("%F %T%z"); } __END__ floating 2011-06-09 08:19:12+0000 America/Los_Angeles 2011-06-09 08:19:12-0700 UTC 2011-06-09 15:19:12+0000 America/New_York 2011-06-09 11:19:12-0400 2011-06-09 11:19:12 America/Los_Angeles 2011-06-09 09:43:52-0700 UTC 2011-06-09 16:43:52+0000 America/New_York 2011-06-09 12:43:52-0400
In reply to Re: Time Convert Question
by Anonymous Monk
in thread Time Convert Question
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |