0

I got publishedAt result from Youtube API but I want convert it to date and time using php how I can do that ?

Published At Text : 2018-08-14T14:30:02.000Z

1
  • 1
    Show us what have you tried, tell us what happened, and we can guide from there.
    – ehymel
    May 14, 2019 at 21:15

2 Answers 2

2

As gray said you can use strtotime() and date() to format the date.

$googleTime = '2018-08-14T14:30:02.000Z';
$strtotimeFormat = strtotime($googleTime);
$dateTimeFormat = date('Y-m-d H:i:s', $strtotimeFormat)
var_dump($dateTimeFormat)

OUTPUT: '2018-08-14 14:30:02'

-1

You can pass it to strtotime() or to DateTime constructor

>>> strtotime('2018-08-14T14:30:02.000Z')
=> 1534257002
>>> new DateTime('2018-08-14T14:30:02.000Z')
=> DateTime @1534257002 {#3353
     date: 2018-08-14 14:30:02.0 +00:00,
   }
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.