I have a form that submits both a date and a time, and I wish to create one \DateTime object based on these values
The $submission['time'] value looks like: 'T09:45:00'
The $submission['date'] value looks like: '2016-07-11'
I've tried
var_dump(\DateTime::createFromFormat(
'Y-m-d TH:i:s', $reportArray['date'] . ' ' . $reportArray['time'])
); // also tried without 'T' (TH:i:s)
However this broke the script.
Is there a simple way to create one \DateTime object from one date string and one time string?
Tin the format represents a time zone, not a 'T'. You could try this format:'Y-m-d \TH:i:s'. The backslash escapes the 'T' to a literal 'T'. Oh, and you really do not need to add in the space.