cms
cms copied to clipboard
Date field doesn't use APP_TIMEZONE
Bug description
In my .env I've set APP_TIMEZONE=America/New_York
When I enable the timepicker, entries show my local time UK, not America/New_York
These two variables use the timezone from the .env
{{ now | format:"H:i:s" }}{{ updated_at | format:"Y-m-d H:i:s"}}
But this variable uses my local (Valet) timezone
{{ date | format:"Y-m-d H:i:s"}}
Is this a bug? Or is there something else I need to configure to get {{ date | format:"Y-m-d H:i:s"}} to use APP_TIMEZONE ?
How to reproduce
- Run the site locally
- Add a timepicker to an entry blueprint
- Set
APP_TIMEZONEto a different timezone than the one you're in - Compare these variables
{{ now | format:"H:i:s" }}{{ updated_at | format:"Y-m-d H:i:s"}}{{ date | format:"Y-m-d H:i:s"}}- I would expect them to pull the date from
APP_TIMEZONEbut{{ date | format:"Y-m-d H:i:s"}}doesn't
Logs
No response
Environment
Environment
Application Name: Statamic
Laravel Version: 11.22.0
PHP Version: 8.3.8
Composer Version: 2.6.5
Environment: local
Debug Mode: OFF
URL: demo.test
Maintenance Mode: OFF
Timezone: America/New_York
Locale: en
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: log
Cache: redis
Database: sqlite
Logs: stack / single
Mail: log
Queue: redis
Session: file
Livewire
Livewire: v3.5.6
Statamic
Addons: 5
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.24.0 PRO
Statamic Addons
jonassiewertsen/statamic-jobs: 1.5.0
jonassiewertsen/statamic-live-search: 2.1.1
jonassiewertsen/statamic-livewire: 3.6.0
statamic/collaboration: 1.0.0
visuellverstehen/statamic-anchor-navigation: 1.0.0
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
In app.php it says date and date-time functions will use APP_TIMEZONE. But that's not what's happening.
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. The timezone
| is set to "UTC" by default as it is suitable for most use cases.
|
*/
'timezone' => env('APP_TIMEZONE', 'UTC'),
Hi, is this something that's likely to be fixed in the near future?
Unfortunatley, I don't think it'll be addressed in the near future.
We have quite a few timezone-related issues open, but they aren't easy to fix because they would require changes to existing data.
But this variable uses my local (Valet) timezone
{{ date | format:"Y-m-d H:i:s"}}
When you push the site to a server, if you configure the server's timezone to also be American/New York, it should output correctly.
Going to close this as we've just merged https://github.com/statamic/cms/pull/11409, which makes a bunch of timezone-related improvements. It'll be released as part of Statamic 6.