我已经为一家出租车公司建立了一个可以正常工作的预订表格,但是我遇到了一个问题,即用户预订未来过早到期的预订。
由于整个表格有点长,我首先要确保用户不会尝试提前不到一个小时进行预订,而不必填写整个表格。
到目前为止,这是我想出的,但它不起作用:
<?php
//Set local time zone.
date_default_timezone_set('America/New_York');
//Get current date and time.
$current_time = date('Y-m-d H:i:s');
//Set reservation time variable
$res_datetime = $_POST['res_datetime'];
//Set event time.
$event_time = strtotime($res_datetime);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Check Date and Time</title>
</head>
<?php
//Check to be sure reservation time is at least one hour in the future.
if (($current_time - $event_time) <= (3600))
{
echo "You must make a reservation at least one hour ahead of time.";
}
?>
<form name="datetime" action="" method="post">
<input name="res_datetime" type="datetime-local" id="res_datetime">
<input type="submit">
</form>
<body>
</body>
</html>
如何创建验证检查以确保预订的日期和时间至少提前一小时?