- strtotime: documentation ( source)
<?php
$date = new \DateTime("now");
$hourString = $date->format('H:i');
if (
strtotime($hourString) > strtotime('12:00:00') && strtotime($hourString) < strtotime('23:59:59') &&
strtotime($hourString) > strtotime('00:00:00') && strtotime($hourString) < strtotime('07:00:00')
) {
echo($hourString);
}