# |
Dec 12th 2017, 16:15 |
flavius |
checking CLI with `php --ini` ... it runs through the same php.ini file |
# |
Dec 12th 2017, 16:15 |
hmic |
right before your code? |
# |
Dec 12th 2017, 16:15 |
hmic |
flavius: did you set the timezone using date_default_timezone_set in the webserver example |
# |
Dec 12th 2017, 16:14 |
flavius |
left is through web server, right is CLI |
# |
Dec 12th 2017, 16:14 |
flavius |
File uploaded https://cakesf.slack.com/files/U75U0UMR9/F8EH650DD/image.png / https://slack-files.com/T053DPNCM-F8EH650DD-7d9507e45a |
# |
Dec 12th 2017, 16:14 |
flavius |
output |
# |
Dec 12th 2017, 16:14 |
flavius |
``` $time = new \Cake\I18n\Time('last day of this year'); dump($time); dump($time->i18nFormat()); dump($time->i18nFormat('YYYY'));``` |
# |
Dec 12th 2017, 16:14 |
flavius |
``` |
# |
Dec 12th 2017, 16:14 |
flavius |
code |
# |
Dec 12th 2017, 16:13 |
neothermic |
(i.e. use `i18nFormat(\IntlDateFormatter::FULL);`) |
# |
Dec 12th 2017, 16:11 |
neothermic |
@flavius for giggles, output the whole timestamp as per what i18nformat thinks it is. I suspect what's happening is you're passing in a timestamp in UTC, but your local timezone in PHP is forward of UTC, so it's correctly outputting 2018. |
# |
Dec 12th 2017, 16:11 |
flavius |
strange, web based it outputs 2017, cli it outputs 2018... still on windows |
# |
Dec 12th 2017, 16:04 |
hmic |
:) |
# |
Dec 12th 2017, 16:04 |
hmic |
and use the cake console to test |
# |
Dec 12th 2017, 16:03 |
flavius |
ok |
# |
Dec 12th 2017, 16:03 |
hmic |
- just to prove to yourself the point of the failure |
# |
Dec 12th 2017, 16:02 |
flavius |
for local development |
# |
Dec 12th 2017, 16:02 |
flavius |
its a xamp instalation |
# |
Dec 12th 2017, 16:02 |
hmic |
try on another env please |
# |
Dec 12th 2017, 16:02 |
hmic |
so it's windows screwing up again :P |
# |
Dec 12th 2017, 16:02 |
flavius |
Windows NT UNIMATRIX 10.0 build 16299 (Windows 10) i586 --- PHP Version 7.1.1 --- ICU version 57.1 |
# |
Dec 12th 2017, 16:00 |
hmic |
which environment are you on? which php and ICU version are you running? |
# |
Dec 12th 2017, 15:59 |
hmic |
yields the same, correct, results: 2017. |
# |
Dec 12th 2017, 15:59 |
hmic |
do again |
# |
Dec 12th 2017, 15:59 |
hmic |
date_default_timezone_set('Europe/Bucharest'); |
# |
Dec 12th 2017, 15:58 |
hmic |
$time->i18nFormat('YYYY'); |
# |
Dec 12th 2017, 15:58 |
hmic |
$time = new \Cake\I18n\Time('last day of this year'); |
# |
Dec 12th 2017, 15:58 |
hmic |
bin/cake console |
# |
Dec 12th 2017, 15:58 |
hmic |
cannot reproduce |
# |
Dec 12th 2017, 15:57 |
flavius |
try the code above and see with your timezone if `i18nFormat('YYYY')` returns 2018 like it does for me |
# |
Dec 12th 2017, 15:57 |
flavius |
btw its Europe/Bucharest in both my code and my php.ini file, so it's the same |
# |
Dec 12th 2017, 15:56 |
flavius |
it shouldn't matter what my php timezone is, my Time object has the timezone already there, the year should be based on that |
# |
Dec 12th 2017, 15:56 |
hmic |
use date_default_timezone_set() to set a timezone before the test |
# |
Dec 12th 2017, 15:56 |
hmic |
it works for me with my timezone (Europe/Berlin) |
# |
Dec 12th 2017, 15:56 |
hmic |
what is your php timezone set to? |
# |
Dec 12th 2017, 15:55 |
flavius |
`$time->format('Y')` outputs 2017 correctly, `$time->i18nFormat('YYYY')` outputs 2018 incorrectly |
# |
Dec 12th 2017, 15:53 |
V99 |
hmic: vendor and plugins folder are empty |
# |
Dec 12th 2017, 15:53 |
flavius |
i'm stumped |
# |
Dec 12th 2017, 15:53 |
flavius |
``` Cake\I18n\Time {#169 +"time": "2017-12-31T17:51:34+02:00" +"timezone": "Europe/Bucharest" +"fixedNowTime": false } "2018" ``` |
# |
Dec 12th 2017, 15:53 |
flavius |
output |
# |
Dec 12th 2017, 15:52 |
flavius |
``` $time = new Time('last day of this year'); dump($time); dump($time->i18nFormat('YYYY')); ``` |