zendframework / zend-expressive-twigrenderer

Twig integration for Expressive
BSD 3-Clause "New" or "Revised" License
25 stars 14 forks source link

Add support for specifying default timezone for twig's date() filter #12

Closed timdev closed 7 years ago

timdev commented 8 years ago

This adds support for configuring twig's default timezone via configuration.

'twig' => [
    'timezone' => 'Europe/Paris'
]
geerteltink commented 8 years ago

Just wondering what the use case is for this. By default Twig uses the default timezone from php.ini. When changing this for Twig only, you make it sort of out of sync with the rest of the application which uses the php.ini setting.

If you want to set it for users from different countries wouldn't it be better to write middleware and detect the locale and / or location and inject it into Twig afterwards.

timdev commented 8 years ago

My use case is an internal app for an organization that happens to operate in a single timezone. I stopped having anything other than 'UTC' in /etc/timezeone, php.ini or my.cnf a long time ago. To me, non-UTC timezones are just part of the date format. This seemed like the most sensible way to meet that requirement, which I imagine isn't uncommon.

weierophinney commented 7 years ago

Targeting 1.2.0, as it provides new features.

weierophinney commented 7 years ago

Thanks, @timdev! Merged to develop for release with 1.2.0