[San-Diego-pm] Converting Time from UTC
Chris Radcliff
chris_radcliff at mac.com
Fri Feb 1 15:57:04 PST 2008
Hi Mark,
There may be a DateTime formatter module that includes your particular
format. For example:
http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.66/lib/DateTime/Format/Natural.pm
There are many to choose from, so you might want to try a few and see
which one does the best (and possibly fastest) job. Each one will let
you go straight from a string to a DateTime object:
my $parser = DateTime::Format::Natural->new();
my $dt = $parser->parse_datetime($date_string);
...and from there you can use DateTime functions as you described.
Hope that helps.
Cheers,
~chris
On Feb 1, 2008, at 3:42 PM, Mark Schoonover wrote:
> Good Afternoon PMs!
>
> I'm trying to convert from UTC to various US timezones. The time
> data is recorded in UTC in a CSV file. What I need to do is convert
> that time to the correct US timezone, plus keep in my daylight
> savings time. I've looked at DateTime, and it will do what I need,
> but I'm missing something basic. My time is not broken out by hms
> seperately, but instead is recorded 00:00 in one field, and mm/dd/
> yyyy in another. I've played around with DateTime, which has an
> is_dst method, but I have no idea how to put the date and time into
> the correct format, and have it create a DateTime object so I can
> convert to the correct timezone.
>
> Any ideas?
>
> TIA
>
> --
> Mark Schoonover, CMDBA
More information about the San-Diego-pm
mailing list