Skip to content

Instantly share code, notes, and snippets.

@pjf
Created July 31, 2009 03:08
Show Gist options
  • Save pjf/159065 to your computer and use it in GitHub Desktop.
Save pjf/159065 to your computer and use it in GitHub Desktop.
Changing the timezone is as easy as ->set_time_zone()
#!/usr/bin/perl -w
use 5.010;
use strict;
use warnings;
use autodie;
use DateTime;
my $dt = DateTime->now;
foreach my $timezone ( qw( Australia/Sydney GMT America/Los_Angeles ) ) {
$dt->set_time_zone( $timezone );;
printf(
"%20s %10s %3s %2s:%2s\n",
$timezone, $dt->ymd, $dt->day_abbr, $dt->hour, $dt->minute
);
}
__END__
Australia/Sydney 2009-07-31 Fri 13:11
GMT 2009-07-31 Fri 3:11
America/Los_Angeles 2009-07-30 Thu 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment