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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, July 01, 2001 11:11 AM
> To: [EMAIL PROTECTED]
> 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.
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to