簡體   English   中英

PHP Date_format警告

[英]PHP Date_format Warning

我有一個帶有下拉標簽的表單:

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.

誰能說出我為什么收到這個警告。

$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));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM