# |
Aug 20th 2019, 12:56 |
admad |
you don't need to much around with those classes if all you need to to is change deefault timezone |
# |
Aug 20th 2019, 12:54 |
spriz |
ofc if you never use FrozenTime and FrozenDate you don't need that :slightly_smiling_face: |
# |
Aug 20th 2019, 12:53 |
spriz |
Nope, I realize that. But I guess "default" is UTC |
# |
Aug 20th 2019, 12:53 |
admad |
they are not there by default, you need to add those statement if you don't need UTC |
# |
Aug 20th 2019, 12:53 |
spriz |
try dis :slightly_smiling_face: https://gist.github.com/Spriz/d396e30451ab263b98c2e3b92dffaedd |
# |
Aug 20th 2019, 12:52 |
martin |
https://github.com/cakephp/app/blob/master/config/bootstrap.php also not in the default bootstrap? |
# |
Aug 20th 2019, 12:51 |
spriz |
Oh well, they could be elsewhere - but we've put them there for things to apply as early as possible |
# |
Aug 20th 2019, 12:51 |
martin |
they are not there? |
# |
Aug 20th 2019, 12:50 |
spriz |
`Date:: setDefaultLocale()` should be in `bootstrap.php` |
# |
Aug 20th 2019, 12:50 |
spriz |
check the values of these 3: ``` \Cake\I18n\Time::getDefaultLocale(); \Cake\I18n\I18n::getLocale(); \Cake\I18n\I18n::getDefaultLocale(); ``` |
# |
Aug 20th 2019, 12:50 |
martin |
where is the Date:: setDefaultLocale ? |
# |
Aug 20th 2019, 12:49 |
martin |
```Cake\I18n\Time Object ( [time] => 2019-08-01T11:30:00+00:00 [timezone] => UTC [fixedNowTime] => ) 2019-08-01 11:30:00``` but still not working |
# |
Aug 20th 2019, 12:49 |
martin |
last two things are in bootstrap |
# |
Aug 20th 2019, 12:48 |
spriz |
and `ini_set('intl.default_locale', Configure::read('App.defaultLocale'));` also AFAIK |
# |
Aug 20th 2019, 12:47 |
spriz |
also make sure `date_default_timezone_set(Configure::read('App.defaultTimezone'));` is in your `bootstrap.php` |
# |
Aug 20th 2019, 12:47 |
spriz |
I don't remember which one |
# |
Aug 20th 2019, 12:47 |
spriz |
or `nl-NL` |
# |
Aug 20th 2019, 12:47 |
spriz |
they should also be `nl_NL` |
# |
Aug 20th 2019, 12:47 |
spriz |
Also check for Date::, FrozenDate::, Time:: and FrozenTime:: `setDefaultLocale()` calls |
# |
Aug 20th 2019, 12:46 |
martin |
APP_DEFAULT_TIMEZONE is not set |
# |
Aug 20th 2019, 12:46 |
spriz |
try setting this in `app.php`: ``` 'defaultLocale' => 'nl_NL', 'defaultTimezone' => 'Europe/Amsterdam', ``` |
# |
Aug 20th 2019, 12:45 |
neon1024 |
Hah, yeah, good point @spriz |
# |
Aug 20th 2019, 12:45 |
neon1024 |
Try outputting a format which includes the timezone |
# |
Aug 20th 2019, 12:45 |
spriz |
is `APP_DEFAULT_TIMEZONE` env var set to `UTC`? |
# |
Aug 20th 2019, 12:45 |
neon1024 |
..and output the same |
# |
Aug 20th 2019, 12:45 |
neon1024 |
Changing that setting should save to your DB at Amsterdam time |
# |
Aug 20th 2019, 12:44 |
neon1024 |
It shouldn’t be |
# |
Aug 20th 2019, 12:44 |
martin |
but when I format time it will be UTC when the object is UTC |
# |
Aug 20th 2019, 12:43 |
martin |
``` 'defaultLocale' => env('APP_DEFAULT_LOCALE', 'nl_NL'), 'defaultTimezone' => env('APP_DEFAULT_TIMEZONE', 'Europe/Amsterdam'),``` |
# |
Aug 20th 2019, 12:43 |
neon1024 |
https://github.com/cakephp/app/blob/master/config/app.default.php#L54 |
# |
Aug 20th 2019, 12:43 |
neon1024 |
I think you set it in app.php using the locale |
# |
Aug 20th 2019, 12:42 |
martin |
default timezone of product is Europe/Amsterdam |
# |
Aug 20th 2019, 12:42 |
martin |
now I need to do `->i18nFormat('YYYY-MM-dd HH:mm:ss', 'Europe/Amsterdam')` |
# |
Aug 20th 2019, 12:42 |
martin |
is it possible to give i18nFormat a default timezone? or do I always need to set the timezone? |
# |
Aug 20th 2019, 12:41 |
martin |
old database, not my choice :( |
# |
Aug 20th 2019, 12:38 |
spriz |
Why would one not keep things in UTC until it hits the frontend? :( |
# |
Aug 20th 2019, 12:34 |
martin |
also fixed in cake 4? :P |
# |
Aug 20th 2019, 12:34 |
martin |
When I save an UTC time object to a Europe/Amsterdam database, it saves the utc time instead of adding 2 hours :( |
# |
Aug 20th 2019, 12:25 |
ndm |
@khalid Yes, queries (instances of `\Cake\Database\Query` or `\Cake\ORM\Query`) are query builder objects. You can create the former via connection objects (`Connection::newQuery()`), and the latter via table objects `Table::query()`. |
# |
Aug 20th 2019, 12:24 |
spriz |
@eax that sounds funky. Is it downright an event listener that listens to events fired in another PHP process? |
# |
Aug 20th 2019, 12:22 |
khalid |
I am sorry I just kind of new to cake still.. |