我有一个带有下拉标记的表单:
MONTH DAY YEAR HOURS MINS
当我在提交表单时检索值时:
$selMonth = htmlentities($_POST['regmonth']);
$selDay = htmlentities($_POST['regday']);
$selYear = htmlentities($_POST['regyear']);
$selHours = htmlentities($_POST['reghours']);
$selMins = htmlentities($_POST['regmins']);
$date = date_create("".$selDay."-".$selMonth."-".$selYear." ".$selHours.":".$selMins."");
$actual_date = date_format($date, 'd-M-Y H:i');
$timestamp = strtotime($actual_date);
//echo $actual_dt.','.$timestamp;
我得到了正确的日期但始终有警告:
Warning: date_format() expects parameter 1 to be DateTime, boolean given in C:\wamp\www\source\form.php on line 37.
有人能说明为什么我会收到此警告。
答案 0 :(得分:0)
$selMonth = htmlentities($_POST['regmonth']);
$selDay = htmlentities($_POST['regday']);
$selYear = htmlentities($_POST['regyear']);
$selHours = htmlentities($_POST['reghours']);
$selMins = htmlentities($_POST['regmins']);
$date = ("".$selYear."-".$selMonth."-".$selDay." ".$selHours.":".$selMins."");
$timestamp = Date("Y-m-d H:i",strtotime($date));