Hi,

 

Probably a simple question, but I'm not seeing the answer... I want to
find out the difference in seconds between two dates, and I thought this
would be the way to do it (see below).  I expected the last output line
to be 'dur is: 1320', which is 22 minutes times 60 seconds, not 'dur is:
0'.  Any guidance from anyone?  I'm sure I'm misunderstanding something
simple and critical...

 

Thanks,

Matt

 

=== Perl code ===

use Data::Dumper;

use DateTime;

use DateTime::Format::Strptime;

 

my $dt1 = DateTime->now->set_time_zone( 'America/Chicago' );

my $dt2 = $dt1->clone->add( minutes => 22 );

 

my $dur = $dt2->subtract_datetime($dt1);

$dur->in_units('seconds');

print Dumper($dur), "\n";

 

 

print "dur is: ", $dur->delta_seconds, "\n";

 

=== Perl code end ===

 

 

=== output ===

$VAR1 = bless( {

                 'seconds' => 0,

                 'minutes' => 22,

                 'end_of_month' => 'wrap',

                 'nanoseconds' => 0,

                 'days' => 0,

                 'months' => 0

               }, 'DateTime::Duration' );

 

dur is: 0

=== output end ===

Reply via email to