0

I receive the data from an API so I can't change the origin... It was working before on my old MySQL, now I moved to a new server and i get this error:

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2018-01-11T22:08:40.826+00:00'

what do I need to do now?

Francesco
  • 24,839
  • 29
  • 105
  • 152

2 Answers2

0
$mysql_format = (new DateTime("2018-01-11T22:08:40.826+00:00"))->format("Y-m-d H:i:s");
Sammitch
  • 30,782
  • 7
  • 50
  • 77
0

You need to format date like "Y-m-d H:i:s" in order to work with MySQL datetime field.

i.e. :

$time = date('Y-m-d H:i:s'); From documentation :

The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.

MESSIAH
  • 1
  • 6