3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); date_default_timezone_set('Europe/Berlin'); function convertToTimestamp($str) { echo "Input: " . $str . "<br>"; $str = trim($str); // date_create(), date_fromat() ab PHP 5.2.0 if (function_exists('date_create') && function_exists('date_format')) { $date = date_create($str); $x = ($date !== false) ? (int)date_format($date, 'U') : false; echo "date_create()"; var_dump( $x ); echo "Entspricht: " . date("Y-m-d H:i", $x); echo "<p><hr></p>"; return; } // Fallback mit strtotime() $ts = strtotime($str); if ($ts == -1) $ts = false; // vor PHP 5.1 kommt -1 bei Fehler echo "strtotoime()"; var_dump($ts); echo "Entspricht: " . date("Y-m-d H:i", $ts); echo "<p><hr></p>\n"; } convertToTimestamp("2012-01-01"); convertToTimestamp("2012-01-01 15:00"); convertToTimestamp("2011-02-29"); convertToTimestamp("foo"); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Input: 2012-01-01<br>date_create()int(1325372400) Entspricht: 2012-01-01 00:00<p><hr></p>Input: 2012-01-01 15:00<br>date_create()int(1325426400) Entspricht: 2012-01-01 15:00<p><hr></p>Input: 2011-02-29<br>date_create()int(1298934000) Entspricht: 2011-03-01 00:00<p><hr></p>Input: foo<br>date_create()bool(false) Entspricht: 1970-01-01 01:00<p><hr></p>

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:
34.56 ms | 402 KiB | 8 Q