Yes, you can. To get the current time as hours/minutes in 24-hour format, just use something like this:
$hoursMins = date('Gi');
If you run this statement at, say, 2:06PM you'll get 1406
. If you run it at 7:15AM you'll get 715
.
Full disclosure: I originally had the format string as Hi
but as bparise correctly explains in another answer, Gi
is better.
To read a small file like yours, use the file_get_contents
function to suck the entire file into a string:
$timesList = file_get_contents('1.csv');
From there, you can "explode" it into an array:
$times = explode(',', $timesList);
Then you can just loop through the array and look for the time that's greater than or equal to the current time. As for the current time, you might be better off with the Gi
format in the date
call as mentioned in another answer because it won't have a leading zero if the hour is less than 10AM.