Jump to content

php/mysql date question


paultfh

Recommended Posts

I figured it out.

My code:
[quote]                //age calculation
                $date1 = strtotime($date);
                $datenow = time();
                $diff = $datenow - $date1;
                $diff /= 86400;
             
                //if age is less than 1 day output in hours else output in days
                if($diff < 1)
                {
                        $diff *= 24;
                        $age = round($diff,1);
                        echo "<td width=\"85%\">".$age." hour(s)";
                }else{
                        $age = round($diff,1);
                        echo "<td width=\"85%\">".$age." day(s)";
             
                } [/quote]
Link to comment
https://forums.phpfreaks.com/topic/15632-phpmysql-date-question/#findComment-63769
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.