Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Problem using DateTime

by Khen1950fx (Canon)
on Aug 04, 2012 at 05:29 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://985382]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-18 14:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found