34
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2013-06-01

今月の月初

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

34
29
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?