DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 966,155 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
mirac sengonul
mirac sengonul

Posted on • Updated on

Timezone for DateTime Field at LaravelΒ Nova

Hi there πŸ‘‹

You can want to see created_at field or more fields like this with timezone. You follow me.

Nova allows us for 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 was able to manipulate created_at field.

We have 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)

Thank you.

Thanks for visiting DEV, we’ve worked really hard to cultivate this great community and would love to have you join us. If you’d like to create an account, you can sign up here.