Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Problem using DateTime

by Khen1950fx (Canon)
on Aug 04, 2012 at 05:29 UTC ( #985382=note: print w/ replies, xml ) Need Help??


in reply to Problem using DateTime

This outputs the days:

#!/usr/bin/perl -l use strict; use warnings; use Data::Dumper; use DateTime; my $bday = DateTime->new( year => 2009, month => 3, day => 13, hour => 8, minute => 16, second => 30, nanosecond => 0, time_zone => 'America/New_York', ); my $now = DateTime->now; my $dtd1 = $now->subtract_datetime($bday); print $dtd1->years . ' years'; print $dtd1->months . ' months'; print $dtd1->weeks . ' weeks'; print $dtd1->days . ' days'; print $dtd1->hours . ' hours'; print $dtd1->minutes . ' minutes'; print $dtd1->seconds . ' seconds'; print $dtd1->nanoseconds . ' nanoseconds';
Output:
3 years 4 months 3 weeks 0 days 18 hours 7 minutes 49 seconds 0 nanoseconds


Comment on Re: Problem using DateTime
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-10-24 08:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls