Skip to content

Configured timezone is not respected in the API #4270

@MrMooky

Description

@MrMooky

Bug Description

When creating a date field in a fieldset, it uses UTC by default and not the timezone set in config/app.php. In my case it is 'timezone' => 'Europe/Berlin'. When setting the date, for example 2021-09-16, the output is "2021-09-15T22:00:00.000000Z".

This makes it more complicated to compare dates with now(). So the bug, at least it seems to me, is that Statamic does not respect the timezone set in my app. Basically, I have to do this in order to make it work:

Carbon::parse($response->json()['data'][0]['starts_on'])->timezone(config('app.timezone'))

This seems to be related to the Content API only.

Environment

Statamic 3.2.4 Pro
Laravel 8.61.0
PHP 8.0.10
jacksleight/bard-paragraph-style 1.0.0
jonassiewertsen/statamic-livewire 2.7.0
octoper/statamic-blade-components 1.0.1
optimoapps/statamic-bard-text-align 1.0.2

Install method:

  • Existing Laravel app

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions