首页 > 解决方案 > 日期显示错误

问题描述

I have a date picker, when the date is selected and submitted, it displays a different date all together.

例如:如果我从日期选择器中选择 04/20/2020 并单击提交,则显示的日期为 01/01/1970。

知道这是为什么吗?

<form action="includes/generatelog.php" method="post"  name="generatelogform">
     Entries in the activity log will be generated for the date entered below.<br><br>
<label>Process Date: </label> <input id="flatpickr" name="date" value"">
 <button type="submit" class="btn btn-primary" name="generatelog">Generate Log Entries</button>

生成日志.php:

<?php 
$con = mysqli_connect("localhost", "admin", "");
$db = mysqli_select_db($con, 'mydate');

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
if(isset($_POST['generatelog']))
{
  $date = date("m-d-Y", strtotime($_POST["date"]));
  $day = date("l");

  echo "Today's date is ", $day,"\n", $date;
?>

这曾经可以工作,但现在不行了。我不确定为什么它显示错误的日期。

标签: php

解决方案


推荐阅读