首頁 > 曲藝

PHP 時間戳函式strtotime

作者:由 亦瀟網路 發表于 曲藝日期:2023-01-24

c語言裡面void什麼意思

在做PHP的途中有很多時候都會用到這個函式,這個函式能幫助做很多事情,所以在此記錄,供我和大家一起使用!方便你我他!

PHP 時間戳函式strtotime

PHP獲取

上個月月底

的時間戳:

strtotime(“last day of last month”, time())

PHP獲取

下個月月初

的時間戳:

strtotime(“first day of next month”, time())

PHP獲取

本月1號

的時間戳:

strtotime(“first day of”, time())

PHP獲取

本月月底

的時間戳:

strtotime(“last day of”, time())

PHP獲取

固定時間的月初

時間戳:

strtotime(“2022-02 first day of”) 獲得2022-02-01的時間戳

PHP獲取

固定時間的月末

時間戳:

strtotime(“2022-02 last day of”) 獲得2022-02-28的時間戳

PHP獲取

若干個小時之後

的時間戳:

strtotime(‘+5 hours’) 獲取5個小時後的時間戳

PHP獲取

若干個小時之前

的時間戳:

strtotime(‘-5 hours’) 獲取5個小時前的時間戳

PHP獲取

若干天后

的時間戳:

strtotime(‘+1 day’) 獲取一天後的時間戳

PHP獲取

一週後的今天

的時間戳:

strtotime(“+1 week”)

PHP獲取

一月後的今天

的時間戳:

strtotime(“+1 month”)

PHP獲取一年後的今天的時間戳:

strtotime(“+1 year”)

如果需要轉Y-m-d格式可以使用date函式

PHP獲取

上個月月底

的時間戳轉Y-m-d

date(“Y-m-d”,

strtotime(“last day of last month”, time())

);

PHP 時間戳函式strtotime

想了解更多精彩內容,快來關注亦瀟網路