Skip to content

Instantly share code, notes, and snippets.

@jagroop
Created March 7, 2018 08:22
Show Gist options
  • Save jagroop/2d101b1c08afb71bd5cc2d285c7041ee to your computer and use it in GitHub Desktop.
Save jagroop/2d101b1c08afb71bd5cc2d285c7041ee to your computer and use it in GitHub Desktop.
sleep time check
public function carbonTest()
{
$tz = 'UTC';
$asia = 'Asia/Calcutta';
date_default_timezone_set($tz);
// $currentTime = carbon()->now()->tz($asia)->format('H:i:s');
$currentTime = '21:01:00';
$currentTime = date('H:i:s', strtotime($currentTime));
$nine = date('H:i:s', strtotime('21:00:00'));
$elev = date('H:i:s', strtotime('23:59:59'));
$twe = date('H:i:s', strtotime('00:00:01'));
$three = date('H:i:s', strtotime('03:00:00'));
if($currentTime > $twe && $currentTime < $three){
echo "Sleep Time 1";
}
else if($currentTime > $three && $currentTime < $nine){
echo "No Sleep TIme 2";
}
else if($currentTime>=$nine && $currentTime <= $elev)
{
echo " Sleep Time 3";
}
else
{
echo "No Sleep Time 4";
}
// dd($currentTime);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment