這篇文章將為大家詳細講解有關php中date轉換時間戳的方法,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
php date轉換時間戳的方法:首先創建PHP示例文件;然后通過“echo strtotime("now"), "\n";”方法將date轉換時間戳即可。
使用strotime函數,代碼如下;
<?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"; echo strtotime("20170808 23:00:01"), "\n"; ?>
擴展資料:
PHP strtotime() 函數
1.strtotime,可以將美國英語格式時間字符串轉換的函數。
2.strtotime()可以用英語的自然語言創建某個時刻的時間戳
3.函數語法:int strtotime(string $time[,int $now])
4.函數作用:將美國英語格式的日期時間字符串轉換成unix時間戳。
關于php中date轉換時間戳的方法就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。