Perl DateTime duration format not displaying years -


i'm having troubles difference calculation between 2 dates.

my $todaydate = datetime->now; @updatedatefields = split /\//, $proteinobj->{lastupdate}; #yyyy/mm/dd  $updatedatetime = datetime->new(     year => @updatedatefields[0],     month=> @updatedatefields[1],     day=> @updatedatefields[2] );  $dayssincelastupdate = $todaydate - $updatedatetime;  $dfd = datetime::format::duration->new(pattern => '%y years, %m months, %e days'); print "last update was: ". $dfd->format_duration($dayssincelastupdate). " ago.\n"; 

and output this:

last update date: 2015/01/13 last update was: 0 years, 22 months, 0 days ago.

it does't display 1 years, 10 months, 0 days ago.

you need enable normalise option in datetime::format::duration object, this

my $dfd = datetime::format::duration->new(     pattern   => '%y years, %m months, %e days',     normalise => 1, ); 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -