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

ptidev's avatar
Level 20

Customizing the format of DateTime fields in Nova4

Looking at the code of the DateTime field, it doesn't look like there's a way to customize the format of how it's rendered. It'll either do toIso8601String() or format(DateTimeInterface::ATOM).

Do you guys know if there's a way to override this?

0 likes
7 replies
ptidev's avatar
Level 20

Thank you for pointing me to this direction.

One advice I got was to use a rendered TextField instead since my goal was to show the seconds in the index or view of a model.

wdelfuego's avatar

You can simply use a rendered TextField, but then you lose sortability and filterability. Apparently this is acceptable to the Nova team because they won't even acknowledge that basic functionality has gone missing without proper warning. It's one thing to launch a paid-for admin package without DateTime formatting; it's another to flat out ignore users who are asking questions about it on your own issue tracker but apparently that's how they decided to do business 🤷‍♂️.

That package I made solves those problems; it allows you to set whatever display format you want and maintains both sortability and filterability on the Index view. You only have to add a call to withDateFormat('Y-m-d H:i:s') with the format you want to be displayed.

2 likes
ptidev's avatar
Level 20

That's true, this package solves problems that can't be handled by a rendered TextField. When I need sorting or filtering, it's great that there's an existing solution for it.

I have no idea what the Nova team thinks about it, but my general view about major releases is that it can break BC or lose functionality. What I can relate to is that there are always a lot of post-release tasks that come up, and it can overwhelm the team's capacity to provide the same level of customer service. It happens to my team as well and it is frustrating.

wdelfuego's avatar

Yeah, BC breaks and functionality losses are absolutely acceptable, no disagreement there. My problem is that I have no idea what the Nova team thinks about it either, although I've asked them several times through different channels. They simply ignore that, even when asked explicitly - it gives me the impression that it's clearly a bug but they're trying not to acknowledge it to save face or something.

I'd be as happy to hear that they consider it a bug that they'll solve sometime later this year as I'd be to hear that they consider a lack of formattable DateTime fields acceptable - I'd know what to expect. But all they do is silently change a bug report into a feature request and stop responding to questions in it.

I'm specifically referring to this issue in their own nova-issues repo on GitHub - https://github.com/laravel/nova-issues/discussions/3929 - in which I ask David Hemphill what their point of view is but he ignores the question and suggests that everything works as intended, when his proposed workaround is clearly not an acceptable solution because it breaks other Nova features. In the meantime, following the Nova 4 documentation to the letter results in errors in the front-end but even after explaining that, they don't confirm that there is at the very least a documentation issue. Meanwhile they're actively responding to other issues very quickly so it's clearly a choice to ignore the questions put forward in the issue. I'm quite disappointed with it.

Shaden's avatar

@wdelfuego Thanks for the package, How can I change how the DateTime Picker displays the date in corresponding format in create and update pages?

Please or to participate in this conversation.