I get a date value from the port. And I want to convert that string value to datetime. But I couldn't figure out how. Deletes 0 at the beginning of the code the way I tried.
Incoming value:
;03122019;164202;
My code:
$data = fread($socket, 1024);
$down= array();
$down= split("#",$data);
$list_n= split(";",$down[$i]);
$time = '';
$time = strval($list_n[1])+''.$list_n[2];
$newformat = date('Y-m-d H:i:s',$time);
echo "Time ---------------> ".$time;
echo $newformat;
Result:
Time ---------------> 3122019164202
3122-01-19 23:01:57
Deleting the initial 0. I want to edit these values and insert them into the database.
I want:
Time ---------------> 2019-12-03 16:42:02