php strtotime 函數(shù)UNIX時間戳
更新時間:2009年01月14日 00:02:13 作者:
int strtotime ( string time [, int now])
本函數(shù)預(yù)期接受一個包含英文日期格式的字符串并嘗試將其解析為 UNIX 時間戳。
如果 time 的格式是絕對時間則 now 參數(shù)不起作用。如果 time 的格式是相對時間則其所相對的時間由 now 提供,或者如果未提供 now 參數(shù)時用當(dāng)前時間。失敗時返回 -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);
}
?>
這個效果和用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);
}
?>
這個效果和用mktime()是一樣的.
您可能感興趣的文章:
- 非常全面的php日期時間運算匯總
- php中日期加減法運算實現(xiàn)代碼
- PHP時間戳 strtotime()使用方法和技巧
- PHP下獲取上個月、下個月、本月的日期(strtotime,date)
- php使用strtotime和date函數(shù)判斷日期是否有效代碼分享
- PHP使用strtotime獲取上個月、下個月、本月的日期
- php使用date和strtotime函數(shù)輸出指定日期的方法
- php強大的時間轉(zhuǎn)換函數(shù)strtotime
- PHP中strtotime函數(shù)使用方法詳解
- PHP使用strtotime計算兩個給定日期之間天數(shù)的方法
- js模仿php中strtotime()與date()函數(shù)實現(xiàn)方法
- php中strtotime函數(shù)用法詳解
- PHP實現(xiàn)針對日期,月數(shù),天數(shù),周數(shù),小時,分,秒等的加減運算示例【基于strtotime】
相關(guān)文章
php定義一個參數(shù)帶有默認值的函數(shù)實例分析
這篇文章主要介紹了php定義一個參數(shù)帶有默認值的函數(shù),實例分析了php參數(shù)帶有默認值的函數(shù)使用技巧,需要的朋友可以參考下2015-03-03PHP面向?qū)ο髮W(xué)習(xí)之parent::關(guān)鍵字
在PHP中不能定義重名的函數(shù),也包括不能再同一個類中定義重名的方法,所以也就沒有方法重載。下面這篇文章主要給大家介紹了PHP面向?qū)ο笾畃arent::關(guān)鍵字的相關(guān)資料,需要的朋友可以參考借鑒,下面來一起看看吧。2017-01-01