【PHP】月末・月初の出力方法

文章出处 : Qiita - http://qiita.com/shoridevel/items/0a2f4a64e55d84919a1c

今月の月初

echo date("Y-m-01", time());

今月の月末

echo date("Y-m-t", time());

前月の月初

/* echo date("Y-m-01",strtotime("-1 month")); */

訂正

$now = strtotime("2013-07-31");
echo date("Y-m-d",strtotime("first day of - 1 month",$now));

前月の月末

/* echo date("Y-m-t",strtotime("-1 month")); */

訂正

$now = strtotime("2013-07-31");
echo date("Y-m-d",strtotime("last day of - 1 month",$now));
原文地址:https://www.cnblogs.com/mslagee/p/5748681.html