I'm trying to create a DateTime from the following string:
2012-02-16 00:45:54.441899
I tried with this format, without success:
Y-m-d H:i:s.*
What can I do? I don't care about the part after the dot.
I'm trying to create a DateTime from the following string:
2012-02-16 00:45:54.441899
I tried with this format, without success:
Y-m-d H:i:s.*
What can I do? I don't care about the part after the dot.
you forgot the microsecond part of the format:
$s = '2012-02-16 00:45:54.441899';
$d = DateTime::createFromFormat('Y-m-d H:i:s.u', $s);//format looks like your string
echo $d->format('Ymd');//output format can be whatever you like