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

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]
[LanX]: lol
[Corion]: Woo hoo! A new Auralnauts episode!
LanX mean unfair and funny
[LanX]: but most java code looks like from one million monkey using eclipse. ..
[Eily]: ah yes, perl's motto, There Is More Than One Monkey Typing It

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2018-04-23 16:08 GMT
Find Nodes?
    Voting Booth?