Jump to content

[SOLVED] Help counting the number of days in inventory


DBookatay

Recommended Posts

look datediff() mysql function

 

I'm obviously doing something wrong cause this is not returning the right number of days...

// Days in inventory
   $date1 = date("Y").'-'.date(d).'-'.date("m"); 
   $date2 = $row['pur_date']; 
   $diff = abs(strtotime($date2) - strtotime($date1)); 
   $years = floor($diff / (365*60*60*24)); 
   $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); 
   $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));

   if ($years !="0") {$years = $years.' yrs, ';} else {$years = NULL;}
   if ($months !="0") {$months = $months.' mnths, ';} else {$months = NULL;}

   $daysIn =  $years.$months.$days.' days';

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.