skip to Main Content

Laravel date cast

Hello Every I want to use Laravel default casts feature, where if I access created_at property of a post model. I would like the following output from the following code: Code: $timepassed = $post->created_at; Desired Output: 2 hours ago The…

VIEW QUESTION

Php – How to create Carbon object from this string: 2022-06-21T05:52:46.648533678Z?

How to create DateTime object with PHP from this string: 2022-06-21T05:52:46.648533678Z? There is nine numbers after 'dot', after seconds. I tried to use next variants: <?php Carbon::createFromFormat('Y-m-dTH:i:s.uP', '2022-06-21T05:52:46.648533678Z'); Carbon::createFromFormat('Y-m-dTH:i:s.vP', '2022-06-21T05:52:46.648533678Z'); And always get an error: The timezone could not be…

VIEW QUESTION

how can I add some hours in PHP/Carbon?

I am using Laravel and have this code: $date = now()->locale('es_ES'); $start_date = $date->isoFormat('D [de] MMMM [de] YYYY') $start_time = $date->isoFormat('HH[H]hh') $end_date = $date->addHours(3)->isoFormat('D [de] MMMM [de] YYYY') $end_time = $date->addHours(3)->isoFormat('HH[H]hh') this is the output start_date : 24 de abril…

VIEW QUESTION
Back To Top
Search