3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php echo $phpdate = strtotime('-1 day').PHP_EOL; $mysqldate = date('Y-m-d H:i:s', $phpdate); function formatDate($date) { if ($date >= strtotime('today')) { return 'Today at ' . date('g:i A', $date); } elseif ($date >= strtotime('yesterday')) { return 'Yesterday at ' . date('g:i A', $date); } else { return date('M j, Y', $date); } } echo formatDate($phpdate); ?>
Output for 5.1.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
1387317041 Notice: A non well formed numeric value encountered in /in/2B5IL on line 5 Notice: A non well formed numeric value encountered in /in/2B5IL on line 12 Yesterday at 10:50 PM
Output for 4.3.10 - 4.4.9, 5.0.3 - 5.0.5, hhvm-3.10.0
1387317041 Yesterday at 10:50 PM
Output for 5.0.2
1387234800 Yesterday at 12:00 AM
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/2B5IL on line 4 1387234800PHP_EOLYesterday at 12:00 AM
Output for 4.3.0 - 4.3.9
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/2B5IL on line 4 1387317041PHP_EOLYesterday at 10:50 PM