Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Carbon time format

I save the user photo with Carbon in laravel 9

$user->photo_verified_at = Carbon::now()->timestamp;

But I get this output from database:

Error Message : ORA-01843: not a valid month
Position      : 42
Statement     : update "USERS" set "PHOTO_VERIFIED_AT" = :p0, "USERS"."UPDATED_AT" = :p1 where "ID" = :p2
Bindings      : [1672340645,2022-12-29 19:04:05,25]

If you a look at the data for created_at and updated_at in the database, they have the following format:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

29/12/22 18:30:43,000000000

How is it possible to set Carbon to return in that format?

Carbon::now()->timestamp->format('dd/mm/yy H:i:s')

it returns

Error: Call to a member function format() on int

>Solution :

You should be fine with just Carbon::now() or now() (it is a helper function calling Carbon::now())

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading