Bug #20389
closedWrong timezone handling
0%
Description
Hello, I was trying to sort out how date/time form values are handling now in BE and I've found next:
In core mailing list ([TYPO3-core] RFC: #18977+#18977+#18977: Fixes for date/time fields issues (timezone and "d")) stated that:
Ernesto Baschny [cron IT] wrote:
Notes:
Since TYPO3 4.2 we changed the handling of timezone: client converts to
UTC before sending form data to server. Server converts from UTC to
server-timezone before storing into database. This solved a lots of
issues regarding server standing on different timezones than the client,
but introduced some minor issues, from which hopefully the last two were
fixed with this patch.Cheers,
Ernesto
1. As written before
Since TYPO3 4.2 ... client converts to
UTC before sending form data to server.
Now I see that in jsfunc.evalfield.js, in evalFunc_convertClientTimestampToUTC() we have next line:
514 timeObj.setTime((timestamp - timeObj.getTimezoneOffset()*60)*1000);
But "The getTimezoneOffset() method returns the difference in minutes between Greenwich Mean Time (GMT) and local time".
So to get UTC we should add timeObj.getTimezoneOffset()*60 to timestamp, not substract.
But we substract and now from client time UTC+TZ we are getting UTC+TZ+TZ instead of UTC. And I've checked values being sent to server, it is really UTC+TZ+TZ, not UTC.
2. Then on server side
As should be:
Server converts from UTC to
server-timezone before storing into database.
We have in class.t3lib_tcemain.php:
02010 case 'datetime':
02011 $value = intval($value);
02012 if ($value>0 && !$this->dontProcessTransformations) {
02013 $value -= date('Z', $value);
02014 }
This code supposed to convert from UTC to server timezone, but date('Z', $value) returns "Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive."
So we see what from date() function we are getting inverted value in compare with getTimezoneOffset() function.
And as mentioned before server is getting UTC+TZ+TZ not UTC from client and finally converts it to UTC+TZ and stores to DB.
At last we have in DB same value as was entered on client side IF client and server in same timezone.
(issue imported from #M11026)
Updated by Dmitry Dulepov over 15 years ago
Do not open bug reports to ask questions. We have mailing lists for this.
Updated by Vladimir Podkovanov over 15 years ago
Hi Dmitry I'm not asking, I'm reporting bug here.
Updated by Ernesto Baschny over 15 years ago
Vladimir, do you have a step-by-step on how to reproduce the error? That would ease us in finding the real issue here.
Updated by Chris topher over 14 years ago
No response for more than a year; also after different notes to provide more information (also in #20241).
Not reproducable.