Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://985382]
help
Chatterbox?
virtualsue will be sweeping/raking it up for days
[virtualsue]: I need to get some cat pics into my talk http://www.cat- lovers-only.com/ images/three-cat- burritos-to-go-500 .jpg
[holli]: put mine in :)
[holli]: instant cat fame
[virtualsue]: nice photo

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2017-11-21 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (300 votes). Check out past polls.

    Notices?