3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $phpdate = strtotime('now'); echo $mysqldate = date('Y-m-d H:i:s', $phpdate); die; /*function formatDate($time) { if ($time >= strtotime("today 00:00")) { return date("g:i A", $time); } elseif ($time >= strtotime("yesterday 00:00")) { return "Yesterday at " . date("g:i A", $time); } elseif ($time >= strtotime("-6 day 00:00")) { return date("l \\a\\t g:i A", $time); } else { return date("M j, Y", $time); } } date_default_timezone_set("America/New_York"); $time = $block["created_at"]; $time = strtotime($time); if(date("now") == date("m-d-Y", $time)) { $time = date("g:ia", $time); } else if(date(strtotime("-1 day")) == date("m-d-Y", $time)) { $time = "Yesterday at" + date("g:ia", $time); } else { $time = date("m-d-Y g:ia", $time); } strtotime("yesterday -1 day $hour:00"); $now = time(); $last_midnight = $now - ($now % (24*60*60)); if ($last_access >= $last_midnight) { print "Today"; } elseif ($last_access >= ($last_midnight-(24*60*60)) { Print "Yesterday"; } function get_day_name($timestamp) { $date = date('d/m/Y', $timestamp); if($date == date('d/m/Y')) { $day_name = 'Today'; } else if($date == date('d/m/Y',now() - (24 * 60 * 60))) { $day_name = 'Yesterday'; } return $date; } print date('G:i:s', $last_access).' '.get_day_name($last_access); die;*/ /*echo $last_access=strtotime('-2 days'); if ($last_access >= strtotime("today")) echo "Today"; else if ($last_access >= strtotime("yesterday")) echo "Yesterday"; else echo 'not yesterday'; $today = date(”m.d.Y”); $yesterday = date(”m.d.Y”, strtotime(”-1 day”)); $mtdate = “<$MTEntryDate format=”%m.%d.%Y”$>”; if ($mtdate==$today) { echo “Today”; } elseif ($mtdate==$yesterday) { echo “Yesterday”; } else { echo(”<$MTEntryDate format=”%A”$>”); }*/ ?>
Output for 4.3.0 - 4.4.9, 5.0.3 - 5.6.25, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
2013-12-18 22:36:52
Output for 5.0.0 - 5.0.2
2013-12-18 00:00:00