[TYPO3-dev] stdwrap->strftime and timezone
David Nyffenegger
david at nyffis.ch
Fri Mar 31 22:05:20 CEST 2006
I have now discovered the behavior...
When entering in the BE a time value, it is done without any timezone in
mind. E.g. if I enter 20:00, then 20 * 3600 = 72000 will be stored in
the DB table. The rendering in the backend is done with the
TCA->config->eval mapping, which in this case is t3lib_BEfunc::time().
This function doesn't use strftime (surprise, surprise), instead it is
made "by hand":
function time($value) {
$hh = floor($value/3600);
$min = floor(($value-$hh*3600)/60);
$sec = $value-$hh*3600-$min*60;
$l =
sprintf('%02d',$hh).':'.sprintf('%02d',$min).':'.sprintf('%02d',$sec);
return $l;
}
This explains, why in the BE, the time inputted is the time shown.
BUT, in the FE, the strftime function is used, which is affected by the
setlocale() function, which is set according the TS config.locale_all
value, which implies in my case a time zone of GMT+1, i.e. strftime adds
the magic hour because it assumes UTC as input.
One solution would be to change the BE code in order to store only real
unix timestamps in the database (UTC). This would affect the rendering
as well as the processing of the form input. The other solution: when
rendering with strftime be aware that user fields containing date and
time information will be in the users timezone, thus transform them
first back to UTC before using strftime.
Regards
David
More information about the TYPO3-dev
mailing list