需要準備的材料分別是:電腦、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天。