Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

philipbaginski's avatar

Date format in BelongsTo relation

I'm lost to solve this problem:

I have one resource (A) with 'date' field - and this field is the only one make sense as a title for this resource. I added date format info into the resourse file:

->format('DD-MM-YYYY'),

, and it displays date proper on Detail view, e.g.: 31-12-2019

But I did relation using BelongsTo with another resource (B) using 'date' field from resource (A), and the date in the choose field and on index view looks just crazy - e.g.:

2017-07-08T22:00:00.000000Z

I will appreciate any idea to solve it.

0 likes
2 replies
fylzero's avatar

@philipbaginski Not crazy... just an ISO string / ISO 8601 string. Can't you just run format again after you call that? Or use Carbon to parse?

I tend to reach for Carbon to process Server/PHP dates and Moment JS to process client side dates with timezones.

24 likes

Please or to participate in this conversation.