Re: FN-FORUM: php date function
date posted 9th May 2006 17:05
On Tuesday 09 May 2006 5:32 pm, Mark Bell wrote:
> I've grabbed this: (from http://us3.php.net/date)
>
> $date1 =3D mktime(0,0,0,1,1,2006);
> $date2 =3D mktime(0,0,0,date('m'),date('d'),date('Y'));
> $total_days =3D 0;
> while($date1 < $date2) { $total_days++; $date1 +=3D 86400; }
> echo $total_days;
Take that code outside and shoot it. Even if that's how you wanted to=20
get your date difference, which you don't, you wouldn't want to do it lik=
e
that...=20
Use MySQL:
SELECT DATEDIFF(CURDATE() - datefield)
or maybe=20
SELECT TO_DAYS(CURDATE()) - TO_DAYS(datefield)) as day_diff
Read this:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html