【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));
posted @ 2016-08-08 11:38  风在山路吹  阅读(215)  评论(0编辑  收藏  举报