0
0

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 3 years have passed since last update.

[PHP]指定月の月末日を取得

Posted at

パラメーターで受け取った値(年と月)を元に、その年月の月末日を取得する。

# 受け取ったパラメーター
$p_y=2021;
$p_m=9

# 後のdate関数で'Y-m-t'フォーマット指定のため
$p_m=str_pad($p_m,2,0,STR_PAD_LEFT);

$last_date = date("Y-m-t", strtotime("$p_y-$p_m-01"));
# $last_date => '2021-09-30'
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?