3v4l.org

run code in 300+ PHP versions simultaneously
<?php function validateDate($date, $format = 'Y-m-d H:i:s') { $d = DateTime::createFromFormat($format, $date); var_dump($d); echo "----------------------------------\n"; echo $d->format($format); echo "----------------------------------\n"; echo $date; echo "----------------------------------\n"; echo $d && $d->format($format) == $date; return; } validateDate('2012-02-30 12:12:12'); validateDate('30/02/2012', 'd/m/Y'); validateDate('14:77', 'H:i'); validateDate('2012-02-28 12:12:12');
Output for git.master, git.master_jit, rfc.property-hooks
object(DateTime)#1 (3) { ["date"]=> string(26) "2012-03-01 12:12:12.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ---------------------------------- 2012-03-01 12:12:12---------------------------------- 2012-02-30 12:12:12---------------------------------- object(DateTime)#1 (3) { ["date"]=> string(26) "2012-03-01 18:21:24.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ---------------------------------- 01/03/2012---------------------------------- 30/02/2012---------------------------------- object(DateTime)#1 (3) { ["date"]=> string(26) "2017-06-14 15:17:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ---------------------------------- 15:17---------------------------------- 14:77---------------------------------- object(DateTime)#1 (3) { ["date"]=> string(26) "2012-02-28 12:12:12.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ---------------------------------- 2012-02-28 12:12:12---------------------------------- 2012-02-28 12:12:12---------------------------------- 1

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
58.72 ms | 403 KiB | 8 Q