Как указывает PHP документация , strtotime()
ожидает, что второй параметр будет ìnt
.
strtotime ( string $time [, int $now = time() ] ) : int
в вашем коде, вы даете строку потому что date () имеет тип возврата string
.
См. этот пример о том, как проверить, было ли задано $lastVisit
вчера:
<?php
$lastVisit = '2020-07-11 14:48:16'; // example value
$lastVisitTimestamp = strtotime($lastVisit); // convert timestamp to int
$lastVisitDate = date("Ymd", $lastVisitTimestamp); // convert $lastVisit to Ymd-String representing
$yesterdayDate = date("Ymd", strtotime('-1 day', time())); // remove one day from current time and convert it to comparable string
// compares two strings f.e "20207010 === 20200711" to check if $lastVisit was yesterday
if($yesterdayDate === $lastVisitDate) {
echo "yeah! last visit was yesterday :)";
} else {
echo "no :(";
}
?>