I have been given a date string from an API in the format e.g.
20120522T143127
I am trying to convert this to a DateTime object, but the object creation fails because of the 'T' (I think).
This is my current code:
$date = DateTime::createFromFormat( "YMDTHis", '20120522T143127' );
$result = $date->format( $format );
What am I missing?
I also tried:
$date = DateTime::createFromFormat( "YMD\THis", '20120522T143127' );
@Rizeranswer.YMDwhen you need to haveYmd. And btw: this is standard format, so just usenew DateTime('20120522T143127')