當前位置:編程學習大全網 - 網站源碼 - php的strtotime('+1 month'),如果是1月31號,應該是2月最後壹天,但是得到的卻是3月2號,怎麽解決這個bug

php的strtotime('+1 month'),如果是1月31號,應該是2月最後壹天,但是得到的卻是3月2號,怎麽解決這個bug

需要準備的材料分別是:電腦、php編輯器、瀏覽器。

1、首先,打開php編輯器,新建php文件,例如:index.php。

2、在index.php中,輸入代碼:$day = '2019-01-31';$r = date('Y-m-d', strtotime('last day of +1 months', strtotime($day)));echo $r;。

3、瀏覽器運行index.php頁面,此時打印出了2月的最後1天。

  • 上一篇:微信小程序訂單導出模板怎麽設置
  • 下一篇:c語言高手請進
  • copyright 2024編程學習大全網