List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:August 3 2001 5:32pm
Subject:Re: Minutes Between Dates
View as plain text  
At 11:53 AM -0300 8/3/01, Augusto Cesar Castoldi wrote:
>HelpHi.
>
>I'm using the timestamp format (AAMMDDHHMMSS) on my session.
>
>how can I know the minutes between two dates.
>
>I'm doing:
>      =20
>       $date       =3D $row_secao['date'];
>       $date_now=3Ddate("ymdHis");   =20
>       $x=3D$date_atual-$date;
>       if ($x > 1000) {
>         echo "Session expired.";  =20
>       }
>       =20
>but I have a problem when turns the hour, like this:
>
>date=3D010803105958
>date_now=3D010803110518
>
>the sub is 4500 (45 minutes!), but in fact, the real time between is 6   =
>=20
>minutes...
>
>is there any function in mysql that does it?
>
>thanks.
>
>Augusto

I'm unable to read your message, but if you're using TIMESTAMP values,
you can determine the difference between them in seconds as follows:

UNIX_TIMESTAMP(ts2) - UNIX_TIMESTAMP(ts1)

To convert that to minutes, just divide by 60.

-- 
Paul DuBois, paul@stripped
Thread
Minutes Between DatesAugusto Cesar Castoldi3 Aug
  • Re: Minutes Between DatesPaul DuBois3 Aug