可能的重复项:
检查字符串是否为 unix 时间戳
我需要在 PHP 上使用正则表达式验证 Unix 时间。例:
<?php
is_unix( $unix )
{
if( preg_match( '/([0-9]+)/' , $unix ) )
{
return true;
}
return false;
}
?>
谢谢;)
怎么样:
function is_unix($t) {
if ( is_numeric($t) && 0<$t && $t<strtotime("some date in the future that you don't expect the value to exceed, but before year 2038") ) {
return true;
}else{
return false;
}