Skip to content

Instantly share code, notes, and snippets.

@mattpramschufer
Last active January 11, 2017 14:04
Show Gist options
  • Save mattpramschufer/4bc0a1f835205e89632d1bff6ddc211a to your computer and use it in GitHub Desktop.
Save mattpramschufer/4bc0a1f835205e89632d1bff6ddc211a to your computer and use it in GitHub Desktop.
Figures out if the current time is during our black out period which we do not want to text users
<?php
/**
* Figures out if the current time is during our black out period which we do not want to text users
*
* @return bool
*/
static public function isDuringBlackOutTime() {
$currentTime = Carbon::now();
if($currentTime->format('A') == 'AM'){
$startBlackout = Carbon::parse('9pm')->subDay(1);
$endBlackout = Carbon::parse('8am');
} else {
$startBlackout = Carbon::parse('9pm');
$endBlackout = Carbon::parse('8am')->addDay(1);
}
return $currentTime->between($startBlackout, $endBlackout);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment