Posted by & filed under TYPO3.

This took me some time to analyze, so I thought I would post it to save time to anyone faced with the same problem.

TYPO3 handles timezones, making sure that whatever input it gets is timezone-aware, both server-side, and client-side. Any input in TCEforms that is set to be evaluated as a datetime must be in GMT. TYPO3 backend automatically converts the timestamps based on client timezone before submitting the date. So if one user is in timezone GMT+1, and another is in GMT-5, and they insert a new record simultaneously, the timestamp in the DB will be the same.

TYPO3 then offsets the timestamp by the server offset. When presenting the result to the user, the timestamp is converted to user’s timezone.

Side note: I tested this in the back end – but I need to check the front end. I would assume it displays the time in server’s timezone. If not, it would be interesting how it works with caching…

When inserting records through the TCE, a time() function is not enough. Due to the processing described above, you must offset your timestamp by the timezone difference with GMT, even if you’re inserting it server side, on the same server that you’re storing it on. You can do it by:
$data[$table][$uid]['datetime'] = intval($data[$table][$uid]['datetime']) + ($GLOBALS['TYPO3_CONF_VARS']['SYS']['serverTimeZone'] * 3600);
This assumes serverTimeZone has been set correctly in the TYPO3 configuration.

One Response to “Timezones in TYPO3”

Leave a Reply

  • (will not be published)