<input type='datetime-local' id='input_time' name='input_time'
value='2018-06-12T19:30' min='2018-06-07T00:00' max='2018-06-14T00:00'>
<input type='datetime-local' id='input_time' name='input_time'
value='2018-06-12T19:30:46'
min='2018-06-07T00:00:56' max='2018-06-14T00:00:34' step=1>
//$dt=$_POST['dt']; // Getting data from POST method of form
$dt="2019-02-16T16:56:49";
$date = DateTime::createFromFormat('Y-m-d\TH:i:s', $dt);
if($date){$msg=' Date object is created using the input ';}
else{$msg=' Unable to create date object ';}
echo $msg;
createFromFormat() to create date and time object
$date = new DateTime(); // Date object using current date and time
$dt= $date->format('Y-m-d\TH:i:s');
echo "<input type='datetime-local' id='input_time' name='input_time' value='$dt'>";
Output is here : $dt_min = date_create('2018-12-31 23:15:40'); // Minimum limit
$dt_min= $dt_min->format('Y-m-d\TH:i:s');
$dt_max = date_create('2015-05-31 20:14:45'); // Maximum limit
$dt_max= $dt_max->format('Y-m-d\TH:i:s');
$dt = new DateTime(); // Date object using current date and time
$dt= $dt->format('Y-m-d\TH:i:s');
echo "<input type='datetime-local' id='input_time' name='input_time' value='$dt' min='$dt_min' max='$dt_max'>";
Output is here
$dt_min = new DateTime('-1 month -10 days');
$dt_min= $dt_min->format('Y-m-d\TH:i:s');
$dt_max = new DateTime('+1 month 10 days'); // Maximum limit
$dt_max= $dt_max->format('Y-m-d\TH:i:s');
$dt = new DateTime(); // Date object using current date and time
$dt= $dt->format('Y-m-d\TH:i:s');
echo "<input type='datetime-local' id='input_time' name='input_time' value='$dt' min='$dt_min' max='$dt_max'>";
Output is here :