RE: [PHP] Time Help

From: Date: Sun, 01 Jul 2001 15:14:15 +0000
Subject: RE: [PHP] Time Help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-55731@lists.php.net to get a copy of this message
Here is the function I use when I am comparing differences ($now and $old are Unix timestamps): function datediff($now, $old) { $DIS = $now - $old; // Diff In Secs $secs = $DIS % 60; // modulo $DIS -= $secs; $days = floor($DIS / (24*60*60)); $DIS -= $days * (24*60*60); $hours = floor($DIS / (60*60)); $DIS -= $hours * (60*60); $mins = floor($DIS / 60); $DIS -= $mins * 60; $diffstr= "$days Days, $hours Hours, $mins Minutes, $secs Seconds"; return $diffstr; } > -----Original Message----- > From: KPortsmout@aol.com [mailto:KPortsmout@aol.com] > Sent: Sunday, July 01, 2001 11:11 AM > To: php-general@lists.php.net > Subject: [PHP] Time Help > > > Hi, > > I`m trying to get the difference between two date/times and then > state how > many days, hours and minutes there are between them. > > So I take my date and convert it into unix time. Then get the > current time, > and then subtract the two to get the current difference in unix > seconds. What > I`m having trouble doing is working out how many days hours and > minutes are > left over. >

« previous php.general (#55731) next »