Menus

Wednesday, 2 November 2016

Yii2 Usefull Tips

How to set timezone in yii


When someone is reffering to application property or application config it means "root" config variable, in this case timeZone.
Config part:
<?php
// in protected/config/main.php
return array(
    'timeZone' => 'Asia/Calcutta'
    // Other configuration....
);

Configure at common/config/main.php:
'components' => [
    ...
    'formatter' => [
        'class' => 'yii\i18n\Formatter',
        'dateFormat' => 'php:j M Y',
        'datetimeFormat' => 'php:j M Y H:i',
        'timeFormat' => 'php:H:i',
        'timeZone' => 'Europe/Berlin',
    ],




No comments:

Post a Comment