3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $currentDate = new DateTime(); $currentDay = $currentDate->format("j"); // Number of days in the current month $daysInMonth = $currentDate->format("t"); var_dump($currentDay); var_dump($daysInMonth);
based on RGSBf
Output for 5.3.19 - 5.4.45, 5.6.15, 5.6.28, 7.0.20 - 7.2.0
string(2) "29" string(2) "31"
Output for 7.0.6
string(1) "3" string(2) "31"
Output for 7.0.5
string(1) "3" string(2) "30"
Output for 7.0.4
string(2) "10" string(2) "31"
Output for 7.0.3
string(2) "18" string(2) "31"
Output for 7.0.2
string(2) "23" string(2) "31"
Output for 5.5.24, 7.0.1
string(2) "24" string(2) "31"
Output for 7.0.0
string(2) "27" string(2) "31"
Output for 5.6.21
string(1) "2" string(2) "31"
Output for 5.6.20
string(2) "10" string(2) "30"
Output for 5.6.19
string(1) "8" string(2) "31"
Output for 5.6.18
string(2) "15" string(2) "31"
Output for 5.6.17
string(2) "19" string(2) "31"
Output for 5.6.16
string(2) "28" string(2) "31"
Output for 5.6.14
string(1) "2" string(2) "30"
Output for 5.6.13
string(2) "15" string(2) "30"
Output for 5.6.12
string(2) "20" string(2) "30"
Output for 5.6.11
string(2) "24" string(2) "30"
Output for 5.6.10
string(2) "25" string(2) "30"
Output for 5.6.9
string(2) "27" string(2) "30"
Output for 5.6.8
string(2) "30" string(2) "30"
Output for 5.5.35
string(2) "22" string(2) "31"
Output for 5.5.34
string(2) "11" string(2) "30"
Output for 5.5.33
string(1) "9" string(2) "31"
Output for 5.5.32
string(2) "17" string(2) "31"
Output for 5.5.31
string(2) "21" string(2) "31"
Output for 5.5.30
string(1) "1" string(2) "30"
Output for 5.5.29
string(2) "17" string(2) "30"
Output for 5.5.28
string(2) "21" string(2) "30"
Output for 5.5.27
string(2) "22" string(2) "30"
Output for 5.5.26
string(2) "26" string(2) "30"
Output for 5.5.25
string(2) "28" string(2) "30"