3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $now = new DateTime(); $now->setTimezone(new DateTimeZone("UTC")); $new_time = strtotime($now->format('Y-m-d H:i:s -12 hours')); $query = "(SELECT * " . "FROM quote q " . "WHERE q.updated_at = 0 AND q.created_at between '" . date('Y-m-d H:i:s', $new_time) . "' AND '" . $now->format('Y-m-d H:i:s') . "') UNION (SELECT * FROM quote k WHERE k.updated_at != 0 AND k.updated_at BETWEEN '" . date('Y-m-d H:i:s', $new_time) . "' AND '" . $now->format('Y-m-d H:i:s') ."')"; echo $query;
based on U5dnl
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0beta1
(SELECT * FROM quote q WHERE q.updated_at = 0 AND q.created_at between '1970-01-01 01:00:00' AND '2017-05-31 15:34:30') UNION (SELECT * FROM quote k WHERE k.updated_at != 0 AND k.updated_at BETWEEN '1970-01-01 01:00:00' AND '2017-05-31 15:34:30')