How do i convert datetime which is in UTC using php/laravel like this format 2017-10-14T22:11:20+0000
I want to convert my date and time like this 2017-10-14T22:11:20+0000 with laravel. In my DB I have saved date with a timestamp. In laravel I have setup timezone as UTC.
I have tried,
$format = "Y-m-d\TH:i:s\+ZZZZ";
$datetime = new \DateTime($value);
return $datetime->format($format);
But is not showing the proper timezone.
Answer
Solution:
`$Parsedate = Carbon::parse($value,'UTC');
$date = Carbon::createFromFormat('Y-m-d H:i:s', $Parsedate);
return $dateD = $date->toAtomString();`
Save your dates as UTC in DB using Carbon, with laravel. So, you can easily change the dates time with respective timezone.
Source