if ((strtotime("1 June") == time()))
{
mysql_connect("localhost","root","");//database connection
mysql_select_db("student");
$order = "UPDATE stud SET class='9' WHERE class='8'";
$result = mysql_query($order); //order executes
}
上面的代码不起作用..我将日期更改为 6 月 1 日..但是 strtotime() 和 time() 返回不同的值..
最佳答案
$cmp = strtotime("19 April");
// convert specified date to int
$current_date = strtotime(date("Y-m-d"));
if ($cmp == $current_date) {
// process
}
time() 函数将为您提供等价的
strtotime(date('Y-m-d H:i:s'));
如果想比较当前日期和给定日期仅使用
strtotime(date('Y-m-d'));
这将给出以下格式的结果
strtotime("19 April");
检查 strtotime 和 date 的文档 http://php.net/manual/en/function.strtotime.php
关于php - 我如何检查日期与当前日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29726357/