$dt->offset is giving you the
+1100 and
-0700 portion of each time format, but in seconds rather than hours, i.e. 11 hours = 39600 seconds and -7 hours = -25200 seconds. You could use the
$dt->epoch method to get the duration in seconds:
my $duration = $dt_received->epoch - $dt_sent->epoch;
print "$duration seconds";
# 27 seconds
For finer grained control of the result you can use
subtract_datetime()
my $duration = $dt_received->subtract_datetime( $dt_sent );
print $duration->minutes, " minutes, ", $duration->seconds, " seconds"
+;
# 0 minutes, 27 seconds
See
DateTime::Duration
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.