Note: You only need to store, read, and judge the time, not including the date.
Such as
Start time: 08:30:00
End Time: 18:00:00
Enter the time in the form as above, can you store it in the MySQL database with an int type, and print it in PHP?
You can also determine whether the current time of the server is between start and end.
Reply to discussion (solution)
Before you save the database, turn the strtotime into 10 digits and then judge the direct ratio.
The string can be stored directly, and it can be compared with the current time.
Storage and read solved, how can I tell? Can you make it a little more specific?
How you store and read, it's best to post code for analysis.
Save:
$_post[' time1 ']= ' 08:00:08 ';
$_post[' time2 ']= ' 16:00:08 ';
$data [' time1 ']=strtotime (In ($_post[' time '));
$data [' Time2 ']=strtotime (In ($_post[' time '));
Read:
$info [' time1 ']=1395100808;
$info [' time2 ']=1395129608;
$time 1=date ("H:i:s", $info [' time1 ']);
$time 2=date ("H:i:s", $info [' time2 ']);
How to determine whether the current server time is:
$time 1
$time 2
Between.
$current = Date ("H:i:s"), if ($current > $time 1 && $current < $time 2) { echo ';} else{ Echo ' non-between ';}
$current = Date ("H:i:s"), if ($current > $time 1 && $current < $time 2) { echo ';} else{ Echo ' non-between ';}
I generally use this method date ("H:i:s") so the output of the result is the landlord to the result