mardi 7 novembre 2017

PHP if date is older than X days

i have some problems with date. I need make if like --->

if your activity is less than 1 day do somethink

else if your activity is more than 1 day and less than 3 do moething else

else if your activity is more than 3 do moething else

I need this in PHP. My actual code is:

if(strtotime(strtotime($last_log)) < strtotime('-1 day') ){
    $prom .= "" . json_encode('last_activity') . ": " . json_encode("inactive less than 1 day") . ",";
}else if(strtotime($last_log) > strtotime('-1 day') && strtotime($last_log) < strtotime('-3 day')){
    $prom .= "" . json_encode('last_activity') . ": " . json_encode("inactive more than 1 day and less than 3 days") . ",";
}else if(strtotime($last_log) > strtotime('-3 day')){
    $prom .= "" . json_encode('last_activity') . ": " . json_encode("inactive more than 3") . ",";
}

I think i realy don't understand that days counting.

Aucun commentaire:

Enregistrer un commentaire