If no timezone conversion should be performed, you need to set $defaultTimeZone and $timeZone to the same value.
The output I get is this:
'America/Sao_Paulo' (length=17)
'America/Sao_Paulo' (length=17)
'America/Sao_Paulo' (length=17)
(DateTime)[303]
public 'date' => string '2019-12-31 23:59:59.000000' (length=26)
public 'timezone_type' => int 3
public 'timezone' => string 'America/Sao_Paulo' (length=17)
'01.01.2020 00:59:59' (length=19)
As you can see, all my timezones are set to America/Sao_Paulo. Despite that, the date changes from 2019-12-31 23:59:59 to 01.01.2020 00:59:59. I would expect the result to be
thank you for your time, however specifying the format ‘php:d.m.y H:i:s’ does not sovle the problem. Changing the timezone in the OS does not have affect either. As far as I remember, when I had the defaultTimezone and timeZone set to the same value, no conversion occurred in the past. For some reason, it doesn’t work now and I can’t figure out why.
And did you tried with a set format without the “php:” prefix?
What is the timezone you defined in your application config? Or did you set it specifically in the formatter?
We set the timezone in the config and the formatter most likely inherits this settings, because I see, it has also the ‘Sao_Paulo’ timezone. I have pin pointed the problem and I can see, that the conversion is done by the IntlDateFormatter object:
I have this personal function adapted to my requirements, I hope it helps you
private function CompuraFechaHora($hora_actual)
{
// captura el la hora de internet
date_default_timezone_set(‘America/Caracas’);
setlocale(LC_TIME, ‘es_VE.UTF-8’);
$fecha_actual=strftime("%Y-%m-%d");
$hora_actual=strftime("%H:%M:%S");
// caso contrario que no la tenga la va tomar del servidor
$hoy = getdate();$hora= $hoy[‘hours’];$minutos= $hoy[‘minutes’];$segundos= $hoy[‘seconds’];
if ($hora_actual==’’){
$hora_actual = $hora;
}
Different PHP versions produce different results. Maybe, this has something to do with the ICU version installed in the OS. My ICU version on my local computer is this:
marusiju@T470s ~/Workspace/ewb/plugins (master) $ php -i |grep -i icu
ICU version => 64.2
ICU Data version => 64.2
ICU TZData version => 2019a
ICU Unicode version => 12.1
libmongoc ICU => disabled
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
There’s a newer version of ICU available (65.1), but I don’t know, how to upgrade it properly. I was able to build the source code of this 65.1 version, but my php installation still uses the old one.