I'm trying to retrieve a date from a date input form and I just can't get it to work properly. The code I'm using now only returns an error and this date: 1970-01-01. That is not correct and I would like to know how I can approach this. This will be used later to query a database table. I want the date to be basically just a string with this format: "yyyy-mm-dd"
Code:
HTML
<form name="DateFilter" method="POST">From:<input type="date" name="dateFrom" value="<?php echo date('Y-m-d'); ?>" /><br/>To:<input type="date" name="dateTo" value="<?php echo date('Y-m-d'); ?>" /></form>
PHP
$new_date = date('Y-m-d', strtotime($_POST['dateFrom']));echo $new_date;
~~~ EDIT ~~~
Fixed Solution for anyone wondering how it's done:
HTML
<form name="Filter" method="POST"> From:<input type="date" name="dateFrom" value="<?php echo date('Y-m-d'); ?>" /><br/> To:<input type="date" name="dateTo" value="<?php echo date('Y-m-d'); ?>" /><input type="submit" name="submit" value="Login"/></form>
PHP
$new_date = date('Y-m-d', strtotime($_POST['dateFrom']));echo $new_date;