php - Trying to determine length (in months and years) based on todays date -
i have online credit app several fields month , year selections (time @ address, hire date, etc) , want not display results (march, 2011) analyst views, length based on when app submitted. unfortunately can not change structure of db, instead need change output of php, have been unsuccessful.
the rows are: "ap_add8" = month (january - december full text,) "ap_add9" = year (2014) , "submitted" = date ap submitted (2014-03-24.)
i've tried`
$difference = abs(strtotime($row['ap_add9'].'-'.date("m", mktime(0, 0, 0, $row['ad_add8']))) - strtotime(date("y").'-'.date(m))); $years = floor($difference / (365*60*60*24)); $months = floor(($difference - $years * 365*60*60*24) / (30*60*60*24)); if ($years !="0") {$years = $years.' years, ';} else {$years = null;} if ($months !="0") {$months = $months.' months';} else {$months = null;}` to working based on todays date, can't working properly.
try getting time today (time() - returns timestamp) convert date when app started timestamp, subtract. use formatting php's date format.
Comments
Post a Comment