ShawnTheMaroon47 :
As per the title, I'm trying to think of a way to limit the user input of a field after the current time. Say if it is 10:00 AM now, the field would only allow input of the time after 10:00 AM, e.g. 11:00 AM, 12:00 PM etc.
I have tried the following but to no avail:
<?php $currenttime = time();
<input type="time" name="time" min="<?php echo $currenttime?>">
I believe this is due to the PHP time() function outputting it as a Unix timestamp, rather than in hours, minutes and seconds. Is there any solution to this? Preferably using PHP or Javascript?
frobinsonj :
You can use date
to format timestamps. If no timestamp is provided to date
, it defaults to the current timestamp.
<?php $currenttime = date("H:i"); ?>
<input type="time" name="time" min="<?php echo $currenttime?>">
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=220526&siteId=1