DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

Developer Manual

Target group: Extension developers

Create a central function in your extension where you format dates and times, e.g. a function formatDateTime($timestamp):

/**
 * Convert time to users timezone if avaiable
 *
 * @param mixed $value
 * @return string The formatted string or, if an error occurred, false.
 */
private function formatDateTime($tstamp) {
    if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('timezones')) {
        // @link http://www.php.net/manual/en/intldateformatter.format.php
        $rc = \Thucke\Timezones\Utility\TimezonesUtility::convertToTimezone($tstamp);
    } else {
        // @link http://www.php.net/manual/en/function.date.php
        $rc = date(DATE_RFC850, $tstamp);
    }
    return $rc;
}

Use this function wherever u need to display dates and/or times. That’s it. No more need to take care of anything else.