LoginSignup
3
0

More than 5 years have passed since last update.

PHPのdate()のtオプションについて

Posted at

概要

今月の残り日数とかを調べたいときに、2,4,6,9,11月(いわゆる「にしむくさむらい」)は月の日数が31日ではないため、いちいち整形する手間が発生する。
date()コマンドのtオプションは、これを解決してくれる。

使い方

date("t");

=> 30 //今日は4月25日のため

今月の日数を入れたければこれでよい。
指定した月の日数(例えば11月)を入れたければ、dateオブジェクトで月を指定する

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