DEV Community

Cover image for Timezone for DateTime Field at Laravel Nova
mirac sengonul
mirac sengonul

Posted on β€’ Edited on

3 1

Timezone for DateTime Field at Laravel Nova

Hi there πŸ‘‹

You may want to see created_at field or more fields like this with timezone.

Nova allows us to override any field.

Date::make('CreatedAt', function () {
                if ($this->created_at) {
                    return sprintf('%s', Carbon::parse($this->created_at)->setTimezone('Europe/Istanbul')->format('Y-m-d'));
                }
           }),
Enter fullscreen mode Exit fullscreen mode

We were able to manipulate the created_at field.

We've been registering the records that date time types without UTC. But after we had made changes, we saw that with timezone.

Have a good day 🎊

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more