Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How to find Date and Time difference?

by Enlil (Parson)
on Jul 08, 2005 at 05:32 UTC ( #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


Comment on Re: How to find Date and Time difference?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-12-29 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (183 votes), past polls