Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
好的,我有一个格式如下的“截止日期”:08/31/2012 (M/D/Y)。我想使用 PHP 将返回的字符串与当前日期进行比较。如果上面的字符串早于当前日期...执行一些代码。
我知道这看起来很简单,但它让我陷入了困境。
谢谢你的帮助!
您的意思是如果字符串日期较旧,则执行此操作,否则执行此操作?
<?php $string = '08/31/2012'; if(strtotime($string) < time()){ echo 'Old'; }else{ echo 'Not happened yet'; }
更改为格式YYYY-MM-DD并简单地作为字符串进行比较。
YYYY-MM-DD