Php 如何将日期与当前日期进行核对
上面的代码不起作用..我将日期更改为6月1日..但是strotime()和time()返回不同的值..您试图根据日期检查时间,请参见 尝试改用date函数Php 如何将日期与当前日期进行核对,php,html,sql,time,strtotime,Php,Html,Sql,Time,Strtotime,上面的代码不起作用..我将日期更改为6月1日..但是strotime()和time()返回不同的值..您试图根据日期检查时间,请参见 尝试改用date函数date('jsf') 再看 time()函数将为您提供 $cmp = strtotime("19 April"); // convert specified date to int $current_date = strtotime(date("Y-m-d")); if ($cmp == $current_date) { //
date('jsf')代码>
再看
time()函数将为您提供
$cmp = strtotime("19 April");
// convert specified date to int
$current_date = strtotime(date("Y-m-d"));
if ($cmp == $current_date) {
// process
}
如果要比较当前日期和给定日期,请仅使用
strtotime(date('Y-m-d H:i:s'));
这将为数据格式提供结果
strtotime(date('Y-m-d'));
检查strottime和date的文档
时间通过计算当前日期为您提供值,这就是为什么它不能为您提供所需的值。为什么要使用date()
函数获取今天的日期?为什么不直接在strotime()
中使用today
关键字???就像这样。是的,它可以。。所有人都有不同的解决问题的方法。谢谢你。。链接
strtotime(date('Y-m-d'));
strtotime("19 April");