I have a function that will check to see if someones status is a certain value and if it is and after a year of it, that persons status will be updated.
Here is the code
if (strtotime($csvstatuschange) < strtotime("-365 day") && (
$csvstatus == "Non-Active, Unable to Monitor - Incidental Business use Exclusion" ||
$csvstatus == "Non-Active - Insurance Cancelled" ||
$csvstatus == "Non-Active - Employee Not Covered Under Listed Policy" ||
$csvstatus == "Non-Active - No Longer Employed" ||
$csvstatus == "Non-Active - Other"
)) {
$status = "Archived";
$wsth = $DBH->prepare("
UPDATE csvdata
SET status = :status,
statuschangedate = :date
WHERE username = :username
");
$wsth->execute(array(
':status' => $status,
':username' => $csvusername,
':date' => $date
));
}
So my issue is – for instance if the persons status is Non-Active - Insurance Cancelled and it was changed today. There status still gets changed.
Thank you for your time!
It seems most likely that
$csvstatuschangeis in a format thatstrtotimecan’t make sense of. As a result it’s returningfalse, which is cast to integer0.0will always be less than 1 year ago.Make sure that the format is one that can be read by
strtotime. My preference isY-m-d H:i:ssince it’s unambiguous. A format liked/m/Ycan be ambiguous becausem/d/Yis also frequently used (is3/4/95the fourth of March or the third of April?)