Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: garbage at end of string in strptime

by Khen1950fx (Canon)
on Feb 16, 2013 at 12:56 UTC ( #1019036=note: print w/ replies, xml ) Need Help??


in reply to Re: garbage at end of string in strptime
in thread garbage at end of string in strptime

What happened to Time::Piece:-). In general, it would be better to use a DateTime::Format::Strptime class like this:

#!/usr/bin/perl -l use strict; use warnings; use DateTime::Format::Strptime qw(); my $format = DateTime::Format::Strptime->new( pattern => '%Y-%m-%d %H:%M:%S', time_zone => 'local', on_error => 'croak', ); my $ts1 = '2012-02-15 00:00:00'; my $dt1 = $format->parse_datetime($ts1); $dt1->add( hours => 3, minutes => 56, seconds => 53, ); print $format->format_datetime($dt1); my $ts2 = '2012-02-15 00:00:00';; my $dt2 = $format->parse_datetime($ts2); $dt2->add( years => 1, hours => 4, minutes => 27, seconds => 25, ); print $format->format_datetime($dt2);


Comment on Re^2: garbage at end of string in strptime
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019036]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2014-08-02 04:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (54 votes), past polls