i wrote a simple method which from a date start it returns how many days hours and seconds were passed.
It returns for example 15000 days 3 hours 3 seconds ago ... seems not good to read at user side.
How can i do better?
For example somenthing like facebook posts time?
can anyone take care on this code?
public function date_diff($start, $end="NOW")
    {
        $timeshift = false;
        $sdate = strtotime($start);
        $edate = strtotime($end);
        $time = $edate - $sdate;
        if($time >= 0 && $time <= 59) {
                // Seconds
              if($time == 1)
               {
                   $s = 'second';
               }
               else
               {
                   $s = 'seconds';
               }
                $timeshift = $time." ".$s;
        } elseif($time>=60 && $time<=3599) {
                // Minutes + Seconds
                $pmin = ($edate - $sdate) / 60;
                $premin = explode('.', $pmin);
                 if($premin[0] == 1)
               {
                   $m = 'min';
               }
               else
               {
                   $m = 'min';
               }
              //  $presec = $pmin-$premin[0];
                //$sec = $presec*60;
                $timeshift = $premin[0]." ".$m;//.round($sec,0); // sec ';
        } elseif($time>=3600 && $time<=86399) {
                // Hours + Minutes
                $phour = ($edate - $sdate) / 3600;
                $prehour = explode('.',$phour);
                $premin = $phour-$prehour[0];
                $min = explode('.',$premin*60);
                 if($prehour[0] > 1)
               {
                   $h = 'hours';
               }
               else
               {
                   $h = 'hour';
               }
                  if($min[0] == 1)
               {
                   $m = 'min';
               }
               else
               {
                   $m = 'min';
               }
           //     $presec = '0.'.$min[1];
            //    $sec = $presec*60;
                $timeshift = $prehour[0]." ".$h." ".$min[0]." ".$m;//.round($sec,0).' sec ';
        } elseif($time>=86400) {
                // Days + Hours + Minutes
                $pday = ($edate - $sdate) / 86400;
                $preday = explode('.',$pday);
                $phour = $pday-$preday[0];
                $prehour = explode('.',$phour*24);
                $premin = ($phour*24)-$prehour[0];
                $min = explode('.',$premin*60);
           //     $presec = '0.'.$min[1];
            //    $sec = $presec*60;
               if($preday[0] > 1)
               {
                   $d = 'days';
               }
               else
               {
                   $d = 'day';
               }
               if($prehour[0] > 1)
               {
                   $h = 'hours';
               }
               else
               {
                   $h = 'hour';
               }
               if($min[0] == 1)
               {
                   $m = 'min';
               }
               else
               {
                   $m = 'min';
               }
               $timeshift = $preday[0]." ".$d." ".$prehour[0]." ".$h." ".$min[0]." ".$m;
        }
        return $timeshift.' ago';
    }
thx and hope someone will enjoy this code
 
     
     
    