I have a form and one of the requirements I need from the user is a specific time. this is done via a drop down menu. An example of a time in the drop down menu is
<option value="06:00:00">6:00 AM</option>
The above saves time as 06:00:00 in mysql database. However I need to compare this time to the current system 开发者_开发技巧time but I get a null value. I tried comparing it with time() but it doesnt work. Converting the 06:00:00 to unix time using strtotime function gives me 838:59:59 as the saved time value in my database for ALL time options.
How can I compare the User input time to the system time. All help will be appreciated.
6AM isn't a timestamp. 6AM on February 7th is a timestamp.
You can't compare them. 6AM is both before 6AM on February 7th (because there was a 6AM yesterday) and after (because there is a 6AM tomorrow).
Once you define what you want this 6AM to mean in your application, you should have some idea how to compare it to the current time (hint: add a date).
use mktime
and time
<?php
$lastpost = mktime(5,15,0,10,1,2002); // mktime is as follows (hour, minute, second, month, day, year)
$timenow = time();
if ($timenow > $lastpost ) {
return true;
} else {
return false;
}
?>
精彩评论