3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php echo $phpdate = strtotime('0 day'); echo PHP_EOL; echo $mysqldate = date('Y-m-d H:i:s', $phpdate); echo PHP_EOL; $last_access = $phpdate; $now = time(); $last_midnight = $now - ($now % (24*60*60)); function friendlyDate($timestamp) { if ((($t1 = floor($timestamp / 86400)) < ($t2 = floor(time() / 86400)) - 2) || $t1 > $t2) return date("M d Y, h:iA", $timestamp); elseif ($t1 == $t2 - 1) return "Yesterday, " . date("h:iA", $timestamp); elseif ($t1 == $t2) return "Today, " . date("h:iA", $timestamp); } echo friendlyDate($phpdate); ?>
Output for 4.3.10 - 4.4.9, 5.0.3 - 5.6.14, 5.6.16 - 7.1.0
1387414037 2013-12-19 01:47:17 Today, 01:47AM
Output for 5.6.15
1387414036 2013-12-19 01:47:16 Today, 01:47AM
Output for 5.0.2
1387407600 2013-12-19 00:00:00 Yesterday, 12:00AM
Output for 5.0.0 - 5.0.1
1387407600 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/TKm0L on line 5 PHP_EOL2013-12-19 00:00:00 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/TKm0L on line 7 PHP_EOLYesterday, 12:00AM
Output for 4.3.0 - 4.3.9
1387414037 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/TKm0L on line 5 PHP_EOL2013-12-19 01:47:17 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/TKm0L on line 7 PHP_EOLToday, 01:47AM