3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $phpdate = strtotime('-100'); $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.10.0 - 3.12.0, 7.0.0 - 7.1.0
Today at 12:48 AM
Output for 4.3.0 - 5.0.5
Jan 1, 1970