Created
February 2, 2021 14:36
-
-
Save gharabaghi/9160b6da511001ff1ceecb049223baf5 to your computer and use it in GitHub Desktop.
php check if hour and minute in form of H:i is before now
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function isHourBeforeNow($hour) | |
{ | |
$now = date('H:i'); | |
$nowArray = explode(':', $now); | |
$hourArray = explode(':', $hour); | |
if ($nowArray[ 0 ] < $hourArray[ 0 ]) { | |
return false; | |
} else if ($nowArray[ 0 ] > $hourArray[ 0 ]) { | |
return true; | |
} else { | |
if ($nowArray[ 1 ] < $hourArray[ 1 ]) { | |
return false; | |
} else { | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment