Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://473333]
[Corion]: :-D
[Corion]: I look forward to your chat client - that should be an interesting example of HTTP / asynchronous stuff

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2017-09-24 14:35 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (274 votes). Check out past polls.