我很难弄清楚如何从日期类型的多个输入表单直接传递到mysql,当我尝试print_r或回显我在这里时,日期总是01-01- 1970年。我在这里看到了类似的问题:stacklink但是我不确定他是如何让它工作的?我错过了什么?
<form method="POST" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<div class="form-group col-lg-offset-2 col-lg-4">
<h3 class="text-center"><strong>Data przybycia:</strong></h3>
<hr />
<input class="form-control" name="dateFrom" value="<?php
echo $dateNextDay; ?>" type="date" min="<?php
echo $dateNextDay; ?>">
</div>
<div class="form-group col-lg-4">
<h3 class="text-center"><strong>Data odjazdu:</strong></h3>
<hr />
<input class="form-control" name="dateTo" value="<?php
echo $dateNextDayNextDay; ?>" type="date" min="<?php
echo $dateNextDayNextDay; ?>">
</div>
PHP:
if($_SERVER["REQUEST_METHOD"] == "POST"){
$ldateFrom = date('Y-m-d', strtotime($POST_['dateFrom']));
$ldateTo = date('Y-m-d', strtotime($POST_['dateFrom']));
答案 0 :(得分:1)
您必须访问$_POST
这样的值,而不是$POST_['dateFrom']
$ldateFrom = date('Y-m-d', strtotime($_POST['dateFrom']));