Project

General

Profile

Actions

Bug #20389

closed

Wrong timezone handling

Added by Vladimir Podkovanov about 15 years ago. Updated about 14 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2009-05-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.3
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

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)


Related issues 2 (0 open2 closed)

Has duplicate TYPO3 Core - Bug #21538: Wrong handling of date-fieldsClosed2009-11-12

Actions
Has duplicate TYPO3 Core - Bug #20241: Change date after saving recordClosed2009-03-26

Actions
Actions #1

Updated by Dmitry Dulepov about 15 years ago

Do not open bug reports to ask questions. We have mailing lists for this.

Actions #2

Updated by Vladimir Podkovanov about 15 years ago

Hi Dmitry I'm not asking, I'm reporting bug here.

Actions #3

Updated by Ernesto Baschny about 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.

Actions #4

Updated by Chris topher about 14 years ago

No response for more than a year; also after different notes to provide more information (also in #20241).

Not reproducable.

Actions

Also available in: Atom PDF