On 2013-04-18 02:00, Ricardo Pais Oliveira wrote:
I'm using DateTime::TimeZone to get my current time. Shouldn't daylight
saving time be handled by the DateTime module?
In $date I'm obtaining the time with less an hour than it should so I
believe DST is not being considered. How can I obtain the current time
regardless it's in DST mode or not?
Here's my script:
use 5.14.2;
use warnings;
use DateTime::TimeZone;
my $tz = DateTime::TimeZone->new( name => 'Europe/Lisbon' );
my $date = DateTime->now();
print $date;
If your box already is in that timezone, you can use localtime().
perl -Mstrict -we'
my @dt = reverse +(localtime)[0..5];
$dt[0] += 1900; # year
$dt[1] += 1; # month
printf qq{%s-%02d-%02d %02d:%02d:%02d\n}, @dt;
'
2013-04-18 09:09:22
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/