【问题标题】:Whats's the code that gives the meaning of your date cannot be more than the current date?给出日期含义的代码不能超过当前日期?
【发布时间】:2013-09-02 06:47:44
【问题描述】:

给出日期含义的代码不能超过当前日期?

<?php
else if($cust_dob  date("d-m-y")){
echo "Error : Your date of birth cannot be in future.";
}

?>

【问题讨论】:

  • $cust_dob 的值是多少? '20-04-1986'? '1990-01-13'?时间戳? DateTime 对象?
  • 他们如何插入生日?为什么不使用下拉菜单而只给出年份的限制。

标签: php sql date


【解决方案1】:

试试下面的代码:

$cust_dob = "2013-09-03";

if(strtotime($cust_dob) > time())
    echo "Error : Your date of birth cannot be in future.";

【讨论】:

  • 如果只能使用time(),为什么还要使用strtotime(date('Y-m-d'))
  • 绝对你是对的!它更快。我使用strtotime 因为之前使用过strtotime($cust_dob)。我想念time()。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多