php - 我如何检查日期与当前日期

标签 php html sql time strtotime

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/

相关文章:

SQL 语句

php - 使用 php/Java 读取 foxpro DB

php - 如何在yii2中制作下拉列表?

php - 将 mysql 查询转换为 codeigniter 查询

javascript - 如何从 mysql 数据库获取行值并通过单击单选按钮填充文本框而不刷新 php 页面?

html - 在 Silverlight RichTextBox 中加载 HTML 内容?

JavaScript 函数在第二次调用时无法获取对 DOM 元素的引用

mysql - 一张大 table 还是多张小 table ?

javascript - 错误 : Expected expression, 脚本结束

php - 输入字段提交最后一个索引,未选择索引