php - Convert Date and Time strings to DateTime -
i'm trying convert date , time datetime format using php:
$matches_date = null; preg_match('/\[(.*[^]])\]/', $line_text, $matches_date); print "date: ".$matches_date[1]."<br>"; $matches_time = null; preg_match('/\(([^)]*)\)/', $line_text, $matches_time); print "time: ".$matches_time[1]."<br>"; $release_date = date("y-m-d h:i:s", strtotime($matches_date[1] + " " + $matches_time[1])); print "datetime: ".$release_date."<br>";
output:
date: 2013-01-30
time: 13:00:00
datetime: 2013-05-10 20:26:00
datetime incorrect. how fix it? tried many variations none worked.
you using wrong operator concatenate. .
not +
$release_date = date("y-m-d h:i:s", strtotime($matches_date[1] . " " . $matches_time[1]));
Comments
Post a Comment