Unless I've misread your dated, the difference is one day and five seconds.
And if you add days to your code:

print "\t".$diff->days, " days\n";

    1 days

On 25 June 2010 03:50, "José M. Perea" <jmpe...@ujaen.es> wrote:

>
>
> Hello,
>
> i'm using the DateTime::Format::Strptime perl module but I find an error
> calculating a period of time between two
> dates in timestamp format. This is my code:
>
> *use DateTime::Format::Strptime;
>
> my $fmt         = '%Y-%m-%d%t%H:%M:%S';
> my $parser      = DateTime::Format::Strptime->new(pattern => $fmt);
>
> my $dt1 = $parser->parse_datetime("2007-01-01 01:04:39") or die;
> my $dt2 = $parser->parse_datetime("2007-01-02 01:05:09") or die;
>
> my $diff = $dt2 - $dt1;
> print "\nPeriod of time:\n";
> print "\t".$diff->hours, " hours\n";
> print "\t".$diff->minutes, " minutes\n";
> print "\t".$diff->seconds, " seconds\n";
>
> And the result is:
>    0 hours
>    0 minutes
>    30 seconds *
>
> Where is the problem?
>
> Thanks!!
> --
>
>

Reply via email to