user4131013 user4131013 - 1 year ago 69
MySQL Question

php how join string date and time separates and convert format Y-m-d H:i:s

I have two string separates date and time, I need you to join these and convert in format Y-m-d H:i:s




$data0 ="214323,131016" ;

$data1 = explode( ',', $data0);

$time = $data1[0];
$date = $data1[1];

I need you 2016-10-13 21:43:23

Answer Source

Use the DateTime class to parse the special format and format it into the desired format.

$dt = DateTime::createFromFormat('His,dmy', '214323,131016');
echo $dt->format('Y-m-d H:i:s');

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download