This is driving me crazy!
Goal: To find out the number of days from when a contract is signed to when it expires.
Problem: Although I can generate time stamps for both the expiration date and signage date, it almost always comes out to 1096 days difference, regardless of the date.
I pull out the date a contract was signed from the DB, for example, 2003-09-22. I increment the year based on the type of contract (Three year for example). So the expiration date would be 2006-09-22.
Here is my code:
/* Get contract date by month, day and year */
list($contract_year, $contract_month, $contract_day) = explode('-', $customer['date_signed']);
/* Get contract_timestamp */
$contract_timestamp = mktime(0, 0, 0, $contract_month, $contract_day, $contract_year, 0);
/* Three year contracts */
if ($customer['contract_type'] == 'Three Year') {
/* Increment year by 3 */
$expiration_year = ($contract_year + 3);
/* Assign logical variable names */
$expiration_month = $contract_month;
$expiration_day = $contract_day;
}
/* Get expiration timestamp */
$expiration_timestamp = mktime(0, 0, 0, $expiration_month, $expiration_day, $expiration_year, 0);
/* Find out the days to expiration */
$days_left = ($expiration_timestamp - $contract_timestamp) / 86400;
I thought maybe I needed to (int) my vars first, but that didn't make a difference. Does anyone have an idea why this is happening?
Thanks,
a9