Skip to content

Instantly share code, notes, and snippets.

@vicenteguerra
Created January 24, 2017 23:02
Show Gist options
  • Save vicenteguerra/cea1fc924f954e0b09666d9eed18f113 to your computer and use it in GitHub Desktop.
Save vicenteguerra/cea1fc924f954e0b09666d9eed18f113 to your computer and use it in GitHub Desktop.
if(isset($item->date) && isset($item->hour)){
$now = \DateTime::createFromFormat('d-m-Y h:i A', $date . " " . $hour);
$fecha = \DateTime::createFromFormat('d-m-Y h:i A', $item->date . " " . $item->hour);
$init_time = $fecha->getTimestamp() - (2 * 60 * 60); // 2 hours
$final_time = $fecha->getTimestamp() + (2 * 60 * 60); // 2 hours
if($now->getTimestamp() > $init_time && $now->getTimestamp() < $final_time) return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment