Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How to find Date and Time difference?

by Enlil (Parson)
on Jul 08, 2005 at 05:32 UTC ( [id://473333]=note: print w/replies, xml ) Need Help??


in reply to How to find Date and Time difference?

I think your code is working fine. In between the two calls to getMeanTime() add a sleep(2); in there and you will find that you will get a difference in seconds instead of no difference at all.That is:
#!/usr/bin/perl use strict; use warnings; use Date::Calc qw(Delta_YMDHMS); my ($day1,$month1,$year1,$hour1,$min1,$sec1) = &getMeanTime; sleep(2); my ($day2,$month2,$year2,$hour2,$min2,$sec2) = &getMeanTime; my ($D_y,$D_m,$D_d, $Dh,$Dm,$Ds) = Delta_YMDHMS( $year1,$month1,$day1, $hour1,$min1,$sec1, $year2,$month2,$day2, $hour2,$min2,$sec2); print sprintf("%02d", $D_d).'/' . sprintf("%02d", $D_m).'/' . sprintf("%04d", $D_y).' ' . sprintf("%02d", $Dh) . ':' . sprintf("%02d", $Dm) . ':' . sprintf("%02d", $Ds); sub getMeanTime { my $time = time; my ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYe +ar, $IsDST) = gmtime($time); $Year+=1900; $Month+=1; return $Day,$Month,$Year,$Hour,$Minute,$Second; } #getMeanTime __END__ 00/00/0000 00:00:02

-enlil

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 16:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found