How to convert String to Date in php? -
this question has answer here:
- convert 1 date format in php 12 answers
i trying date in d/m/y h:i
format. here's code
$datestr = "28/07/2016 10:00"; echo date('d/m/y h:i', strtotime($datestr));
here's ouput:
01/01/1970 01:00
i trying convert other formats, result still same date. know kind of obvious still can't understand why i'm getting date result.
you can use datetime class , it's createfromformat method parse string date in required format.
like this,
$date = datetime::createfromformat('d/m/y h:i', "28/07/2016 10:00"); $date = $date->format('y-m-d h:i:s'); echo $date;
Comments
Post a Comment