简体   繁体   中英

If greater equal than - variable is a date value (from date format) - PHP

This is my code:

$interval->format('%d');

if ($interval >= '1') {
$message = "welcome back!";
}
else
{
    $message = "meh";
}

This is not working because $interval is a date format.

I tried to convert it using:

$interval = strval($interval);

I am tryning to convert $interval to a number or string so that I can do the comparison - becaue right now, the if then else returns welcome back always.

How do I fix this?

这对我有用

if($interval->format('%d') >= 1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM