Edited at

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

More than 5 years have passed since last update.


今月の月初

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));