-3

I am getting data from a webservice but they send date with this format "yyyymmddThhmmss0+0000" and when i try to create a new DateTime from this format i get this error "DateTime::__construct(): Failed to parse time string ..."

  • example: "20161122T1030090+0000"

Does anyone have a idea of what kind of format is that, and how to instanciate a dateTime from it ?

Thank you.

web hobbit
  • 501
  • 4
  • 17

2 Answers2

4

You can use DateTime::createFromFormat(), with escaping the '\T' and extra 0:

$dt = DateTime::createFromFormat('Ymd\THis\0T','20161122T1030090+0000');
echo $dt->format("Y-m-d H:i:s") ;

Outputs:

2016-11-22 10:30:09
Syscall
  • 19,327
  • 10
  • 37
  • 52
-1

It is UTC format, you should convert it to mm/dd/yyyy HH:MM:SS Format

Naveen
  • 25
  • 3