3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $phpdate = strtotime('now'); $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 4.3.0 - 4.4.9, 5.0.3 - 7.1.7
Today at 10:47 PM
Output for 5.0.0 - 5.0.2
Today at 12:00 AM