Re: Timestamps operations

From: Date: Fri, 24 Aug 2001 15:50:33 +0000
Subject: Re: Timestamps operations
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-64277@lists.php.net to get a copy of this message
"Alberto" <alberto@sdrsl.com> wrote in message news:20010824104242.86203.qmail@pb1.pair.com... > I have 2 timestamps like mktime(0,0,0,10,10,2001) and > mktime(0,0,0,9,9,2001), I want to know how many days are from timestamp1 to > timestamp2 or how many hours, or how many seconds, thnx define("SECONDS_PER_DAY", 86400); define("SECONDS_PER_HOUR", 3600); define("SECONDS_PER_MINUTE", 60); $seconds = abs($time2 - $time1); $days = (int) ($seconds / SECONDS_PER_DAY); $seconds -= $days * SECONDS_PER_DAY; $hours = (int) ($seconds / SECONDS_PER_HOUR); $seconds -= $hours * SECONDS_PER_HOUR; $minutes = (int) ($seconds / SECONDS_PER_MINUTE); $seconds -= $minutes * SECONDS_PER_MINUTE; printf("Total time elapsed was %d d %d:%02d:%02d", $days, $hours, $minutes, $seconds);

« previous php.general (#64277) next »