未在
MySQL中设置的日期时间字段将返回到0000-00-00 00:00:00
什么是确定日期是否未在PHP中设置的最佳方法?
没有,如果这些工作:
if($date) //will return true because it is a valid string
if(empty($date)) //will also return true.
if(strtotime($date)) //I thought this would work but it returns a negative number and is true.
我可以用:
if($date == '0000-00-00 00:00:00')
但是,如果我然后将列类型更改为日期,它将会中断.所以我也不喜欢这个.
我正在寻找像is_date这样的东西,但我能找到的是一个名为checkdate的函数,它似乎不是我想要的.
我想我可以使用:
if(strtotime($date) > 0)
我没有看到任何明显的问题,但我仍然认为可能有更好的东西.
标准方式是什么?