php对手时间戳判断,PHP 中判断一个数字是否是Unix 时间戳
PHP 中判斷一個(gè)數(shù)字是否是Unix 時(shí)間戳
在php中一個(gè)有效的時(shí)間是從 1970-01-01 07:00:00 – 2038-01-19 03:14:07。
首先一個(gè)時(shí)間戳中肯定沒(méi)有小數(shù)點(diǎn).
將 1970-01-01 07:00:00 和 2038-01-19 03:14:07轉(zhuǎn)換成時(shí)間戳。
echo strtotime('2038-01-19 03:14:07'); // 2147454847
echo strtotime('1970-01-01 07:00:00'); // 0
方法一:
function isTimeStamp($timestamp) {
return ctype_digit($timestamp) && $timestamp <= 2147483647;
}
方法二:
function is_timestamp($timestamp) {
if (strtotime(date('m-d-Y H:i:s', $timestamp)) === $timestamp) {
return $timestamp;
} else return false;
}
/php/23132.htmlwww.phpzy.comtrue/php/23132.htmlTechArticlePHP 中判斷一個(gè)數(shù)字是否是Unix 時(shí)間戳 在php中一個(gè)有效的時(shí)間是從 1970-01-01 07:00:00 – 2038-01-19 03:14:07。 首先一個(gè)時(shí)間戳中肯定沒(méi)有小數(shù)點(diǎn). 將 1970-01-01 07:00:00 和 2038-01-19 03:14:07轉(zhuǎn)換成時(shí)間...
總結(jié)
以上是生活随笔為你收集整理的php对手时间戳判断,PHP 中判断一个数字是否是Unix 时间戳的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: php页面栏目访问权限,PHPCMS 栏
- 下一篇: lnmp php fpm 默认,LNMP