php getting null date if value is not set by user

  Kiến thức lập trình

I have a html form with a date input.If i disable the input and set its value to a specific date when inserting this value to MySQL I get 1970-01-01 (null date). If I let the user choose the date from then input it works fine and the choose date is stored.

if (isset($_POST[“submit”])) {

$datai = date(‘Y-m-d’,strtotime($_POST[‘datai’]));


document.getElementById(“datai”).disabled = true;

tried to remove the date and strtotime but got index error.

LEAVE A COMMENT