0

I have time from date picker that looks like this: 2017-12-10T14:40:18.492Z. I tried to use the code below in Laravel to convert it to MySQL date format but it is throwing up error saying that (1/1) FatalThrowableError Class 'iirs_demo\Http\Controllers\DateTime' not found

<?php $date = new DateTime('2000-01-01'); echo $date->format('Y-m-d H:i:s'); ?>

Please, how do I resolve it?

Thanks.

Laerte
  • 7,013
  • 3
  • 32
  • 50
cjustinobi
  • 339
  • 1
  • 5
  • 11

1 Answers1

7

PHP is not finding the correct path. For this, use a \ before the function:

<?php $date = new \DateTime('2000-01-01'); echo $date->format('Y-m-d H:i:s'); ?>
Laerte
  • 7,013
  • 3
  • 32
  • 50