《PHP實例:php強大的時間轉換函數(shù)strtotime》要點:
本文介紹了PHP實例:php強大的時間轉換函數(shù)strtotime,希望對您有用。如果有疑問,可以聯(lián)系我們。
使用strtotime可以將各種格局的時間字符串轉換為時間戳PHP實例
轉換慣例時間格式
PHP實例
echo date('Y-m-d H:i:s', strtotime('2016-01-30 18:00')).PHP_EOL; echo date('Y-m-d H:i:s', strtotime('20160130180001')).PHP_EOL;
轉換自然光陰描述
PHP實例
//昨天 echo date('Y-m-d H:i:s', strtotime('yesterday')).PHP_EOL; //上周 echo date('Y-m-d H:i:s', strtotime('last week')).PHP_EOL; //本周開始光陰 echo date('Y-m-d H:i:s', strtotime('this week midnight')).PHP_EOL; //本月開始光陰 echo date('Y-m-d H:i:s', strtotime('first day of this month midnight')).PHP_EOL; //計算相對光陰 echo date('Y-m-d H:i:s', strtotime('+1 month')).PHP_EOL;
完整的php光陰描述文檔可以參考 http://php.net/manual/zh/datetime.formats.relative.phpPHP實例
《PHP實例:php強大的時間轉換函數(shù)strtotime》是否對您有啟發(fā),歡迎查看更多與《PHP實例:php強大的時間轉換函數(shù)strtotime》相關教程,學精學透。維易PHP學院為您提供精彩教程。
轉載請注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/7532.html