1
1

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でdate関数を使って簡単に、月末を求める方法

Posted at

パーフェクトPHP (PERFECT SERIES 3)

date()関数と、mktime()関数を利用します。結構簡単なので、驚きますよ。

 

 

 

1. 今月末

現在の月に「+1」します。

$day = date('Y-m-d', mktime(0, 0, 0, date('m') + 1, 0, date('Y')));

2. 来月末

現在の月に「+2」します。

$day = date('Y-m-d', mktime(0, 0, 0, date('m') + 2, 0, date('Y')));

簡単でしょ!?

1
1
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?