strtotime() 不 return 假
strtotime() doesn't return false
当我提供仅包含 space 或任何其他字符的字符串时,strtotime(" ")
不会 return false。
是否有任何更少的代码解决方案使其 return 错误?
我无法使用 preg_match
,因为日期格式因每个用户的语言环境而异。
http://php.net/manual/en/function.strtotime.php
Returns a timestamp on success, FALSE otherwise. Previous to PHP
5.1.0, this function would return -1 on failure.
编辑:我需要验证日期字符串,而不是 trim spaces 或其他用户提供的字符。
strtotime(" ")
不会 return false。
是否有任何更少的代码解决方案使其 return 错误?
我无法使用 preg_match
,因为日期格式因每个用户的语言环境而异。
http://php.net/manual/en/function.strtotime.php
Returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0, this function would return -1 on failure.
编辑:我需要验证日期字符串,而不是 trim spaces 或其他用户提供的字符。