-1

I want to convert the date format which was coming from a third-party API The date time format which I got from third-party API is July, 17 2020 09:29:00-0500 and I want to convert it in this format 2022-07-17 09:29:00-0500.

Hugh Hari
  • 1
  • 2
  • 1
    Does this answer your question? [Laravel: how to set date format on model attribute casting?](https://stackoverflow.com/questions/37857479/laravel-how-to-set-date-format-on-model-attribute-casting) – Abdulla Nilam Sep 30 '22 at 05:28
  • Welcome to SO. Please try searching before posting a new question - there are hundreds of answers to this here already. – Don't Panic Sep 30 '22 at 07:23
  • Does this answer your question? [change the date format in laravel view page](https://stackoverflow.com/questions/40038521/change-the-date-format-in-laravel-view-page) – Don't Panic Sep 30 '22 at 07:23

1 Answers1

0

I got the answer. I hope it will help others

use Carbon\Carbon;

Carbon::createFromFormat('M, d Y H:i:sT','July, 17 2020 09:29:00-0500')->format('Y-m-d H:i:s');

Hugh Hari
  • 1
  • 2