php strtotime 函數(shù)UNIX時(shí)間戳
更新時(shí)間:2009年01月14日 00:02:13 作者:
int strtotime ( string time [, int now])
本函數(shù)預(yù)期接受一個(gè)包含英文日期格式的字符串并嘗試將其解析為 UNIX 時(shí)間戳。
如果 time 的格式是絕對(duì)時(shí)間則 now 參數(shù)不起作用。如果 time 的格式是相對(duì)時(shí)間則其所相對(duì)的時(shí)間由 now 提供,或者如果未提供 now 參數(shù)時(shí)用當(dāng)前時(shí)間。失敗時(shí)返回 -1。
<?php
echo strtotime ("now"), "\n";
echo strtotime ("10 September 2000"), "\n";
echo strtotime ("+1 day"), "\n";
echo strtotime ("+1 week"), "\n";
echo strtotime ("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime ("next Thursday"), "\n";
echo strtotime ("last Monday"), "\n";
?><?php
$str = 'Not Good';
if (($timestamp = strtotime($str)) === -1) {
echo "The string ($str) is bogus";
} else {
echo "$str == ". date('l dS of F Y h:i:s A',$timestamp);
}
?>
這個(gè)效果和用mktime()是一樣的.
<?php
echo strtotime ("now"), "\n";
echo strtotime ("10 September 2000"), "\n";
echo strtotime ("+1 day"), "\n";
echo strtotime ("+1 week"), "\n";
echo strtotime ("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime ("next Thursday"), "\n";
echo strtotime ("last Monday"), "\n";
?><?php
$str = 'Not Good';
if (($timestamp = strtotime($str)) === -1) {
echo "The string ($str) is bogus";
} else {
echo "$str == ". date('l dS of F Y h:i:s A',$timestamp);
}
?>
這個(gè)效果和用mktime()是一樣的.
您可能感興趣的文章:
- 非常全面的php日期時(shí)間運(yùn)算匯總
- php中日期加減法運(yùn)算實(shí)現(xiàn)代碼
- PHP時(shí)間戳 strtotime()使用方法和技巧
- PHP下獲取上個(gè)月、下個(gè)月、本月的日期(strtotime,date)
- php使用strtotime和date函數(shù)判斷日期是否有效代碼分享
- PHP使用strtotime獲取上個(gè)月、下個(gè)月、本月的日期
- php使用date和strtotime函數(shù)輸出指定日期的方法
- php強(qiáng)大的時(shí)間轉(zhuǎn)換函數(shù)strtotime
- PHP中strtotime函數(shù)使用方法詳解
- PHP使用strtotime計(jì)算兩個(gè)給定日期之間天數(shù)的方法
- js模仿php中strtotime()與date()函數(shù)實(shí)現(xiàn)方法
- php中strtotime函數(shù)用法詳解
- PHP實(shí)現(xiàn)針對(duì)日期,月數(shù),天數(shù),周數(shù),小時(shí),分,秒等的加減運(yùn)算示例【基于strtotime】
相關(guān)文章
php安裝ssh2擴(kuò)展的方法【Linux平臺(tái)】
這篇文章主要介紹了php安裝ssh2擴(kuò)展的方法,結(jié)合實(shí)例形式演示了基于Linux平臺(tái)的ssh2擴(kuò)展安裝步驟與相關(guān)注意事項(xiàng),需要的朋友可以參考下2016-07-07php定義一個(gè)參數(shù)帶有默認(rèn)值的函數(shù)實(shí)例分析
這篇文章主要介紹了php定義一個(gè)參數(shù)帶有默認(rèn)值的函數(shù),實(shí)例分析了php參數(shù)帶有默認(rèn)值的函數(shù)使用技巧,需要的朋友可以參考下2015-03-03PHP面向?qū)ο髮W(xué)習(xí)之parent::關(guān)鍵字
在PHP中不能定義重名的函數(shù),也包括不能再同一個(gè)類中定義重名的方法,所以也就沒有方法重載。下面這篇文章主要給大家介紹了PHP面向?qū)ο笾畃arent::關(guān)鍵字的相關(guān)資料,需要的朋友可以參考借鑒,下面來一起看看吧。2017-01-01