3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $phpdate = strtotime('now'); $mysqldate = date('Y-m-d H:i:s', $phpdate); function formatDate($time) { if ($time >= strtotime("today")) { return date("g:i A", $time); } elseif ($time >= strtotime("yesterday")) { return "Yesterday at " . date("g:i A", $time); } else { return date("M j, Y", $time); } } echo formatDate($phpdate); ?>
Output for 4.3.0 - 4.4.9, 5.0.3 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
10:44 PM
Output for 5.0.0 - 5.0.2
12:00 AM