【发布时间】:2022-02-07 21:40:28
【问题描述】:
$examDay1 = date("07.02.2022");
$examDay2 = date("18.03.2022");
$examDay3 = date("06.04.2022");
$today = date("d.m.Y");
print_r($examDay1 <= $today); //true
print_r($examDay2 <= $today); // false as I expected
print_r($examDay3 <= $today); // true for some reason
我正在尝试在相同的特定日期向用户授予访问权限。例如,其中一个从今天开始,并且比较效果很好。然而,不知何故,它说$examDay3 <=$today 给了true。我做错了什么?
【问题讨论】:
-
因为您正在比较字符串,这仅适用于 ymd 格式。这回答了你的问题了吗? How can I compare two dates in PHP?