3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $paymentdate = "Wed May 13 2015 22:55:49 GMT-0400 (GMT Daylight Time)"; $start = strpos($paymentdate, "GMT"); echo $start . " start\n"; $paystr = substr($paymentdate, 0, $start); echo $paystr . " left\n"; $paystr1 = substr($paymentdate, $start); echo $paystr1 . " right\n"; $paystr2 = substr($paystr1, 3); echo $paystr2 . " offset\n"; $start1 = strpos($paystr2, "GMT"); echo $start1 . " left date string\n"; $paystr3 = substr($paystr2, 0, $start1 - 2); echo $paystr3 . " left date\n"; date_default_timezone_set('Europe/London'); $bool = date('I'); // this will be 1 in DST or else 0 echo $bool . " bool\n"; $paystr4 = substr($paystr3, 0, 1); echo $paystr4 . " offset sign\n"; $paystr5 = substr($paystr3, 1); echo $paystr5 . " offset number\n"; $paytime = strtotime($paystr); echo $paytime . " paytime\n"; $mdate = date('Y-m-d H:i:s', $paytime); echo $mdate . " mdate\n"; $dy = date("d", strtotime($mdate)); echo $dy . " dy\n"; $hr = date("H", strtotime($mdate)); echo $hr . " hr\n"; $paystr6 = substr($paystr5, 0, 2); if (intval($paystr6) > 12) { $paystr6 = substr($paystr5, 1, 1); } echo $paystr6 . " paystr6\n"; $payhr = intval($paystr6); echo $payhr . " payhr\n"; $nochange = 0; if ($paystr4 == "+") { if ($bool == 1) { if ($paystr3 == "+0100") { $nochange = 1; } if ($nochange == 0) { $change = $payhr - 1; $hr = $hr - $change; echo $paytime . " paytime\n"; $paytime = strtotime("-$change hours", $paytime); echo $paytime . " paytime\n"; if ($hr < 0) { $paytime = strtotime("-1 day", "+24 - abs($hr) hours", $paytime); echo $paytime . " paytime\n"; $dy = $dy - 1; $hr = 24 - abs($hr); } } } if ($bool == 0) { if ($paystr3 == "+0000") { $nochange = 1; } if ($nochange == 0) { $change = $payhr . " payhr\n"; $hr = $hr - $change; $paytime = strtotime("-$change hours", $paytime); if ($hr < 0) { $paytime = strtotime("-1 day", "+24 - abs($hr) hours", $paytime); $dy = $dy - 1; $hr = 24 - abs($hr); } } } } if ($paystr4 == "-") { if ($bool == 1) { $change = $payhr; echo $change . " change\n"; $hr = $hr + $change; echo $hr . " hr\n"; $paytime = strtotime("+$change hour", $paytime); if ($hr > 24) { $paytime = strtotime("+1 day", "+23 - abs($hr) hours", $paytime); $dy = $dy + 1; $hr = abs($hr) - 23; } } if ($bool == 0) { $change = $payhr; $hr = $hr + $change; $paytime = strtotime("+$change hour", $paytime); if ($hr > 24) { $paytime = strtotime("+1 day", "+24 - abs($hr) hours", $paytime); $dy = $dy + 1; $hr = abs($hr) - 24; } } } echo $change . " change\n"; echo $hr . " hr\n"; echo $dy . " dy\n"; echo $paytime . " paytime\n"; ?>
Output for 5.2.1 - 7.2.0
25 start Wed May 13 2015 22:55:49 left GMT-0400 (GMT Daylight Time) right -0400 (GMT Daylight Time) offset 7 left date string -0400 left date 1 bool - offset sign 0400 offset number 1431554149 paytime 2015-05-13 22:55:49 mdate 13 dy 22 hr 04 paystr6 4 payhr 4 change 26 hr Warning: strtotime() expects at most 2 parameters, 3 given in /in/5AVff on line 95 4 change 3 hr 14 dy paytime
Output for 5.1.0 - 5.2.0
25 start Wed May 13 2015 22:55:49 left GMT-0400 (GMT Daylight Time) right -0400 (GMT Daylight Time) offset 7 left date string -0400 left date 1 bool - offset sign 0400 offset number 1431554149 paytime 2015-05-13 22:55:49 mdate 13 dy 22 hr 04 paystr6 4 payhr 4 change 26 hr 4 change 3 hr 14 dy paytime
Output for 5.0.0 - 5.0.5
25 start Wed May 13 2015 22:55:49 left GMT-0400 (GMT Daylight Time) right -0400 (GMT Daylight Time) offset 7 left date string -0400 left date Fatal error: Call to undefined function date_default_timezone_set() in /in/5AVff on line 16
Process exited with code 255.
Output for 4.4.5 - 4.4.9
25 start Wed May 13 2015 22:55:49 left GMT-0400 (GMT Daylight Time) right -0400 (GMT Daylight Time) offset 7 left date string -0400 left date Fatal error: Call to undefined function: date_default_timezone_set() in /in/5AVff on line 16
Process exited with code 255.
Output for 4.3.2 - 4.4.4
25 start Wed May 13 2015 22:55:49 left GMT-0400 (GMT Daylight Time) right -0400 (GMT Daylight Time) offset 7 left date string -0400 left date Fatal error: Call to undefined function: date_default_timezone_set() in /in/5AVff on line 16
Process exited with code 255.
Output for 4.3.0 - 4.3.1
25 start Wed May 13 2015 22:55:49 left GMT-0400 (GMT Daylight Time) right -0400 (GMT Daylight Time) offset 7 left date string -0400 left date Fatal error: Call to undefined function: date_default_timezone_set() in /in/5AVff on line 16