trntv / yii2-datetime-widget

Yii2 Date/Time Widget
8 stars 14 forks source link

timezone problem #12

Open trinkity opened 7 years ago

trinkity commented 7 years ago

My $model->date_s = 2017-03-06 19:00:00

But the input field default is 2017-03-06T20:00:00+0100

if in phpDatetimeFormat i insert eg yyyy-MM-DD HH:mm:ss i've error because is not in your protected $defaultPhpMomentMapping

this is the config ` $form->field($model_post, 'schedule')->widget(

    'trntv\yii\datetime\DateTimeWidget',
    [
        'phpDatetimeFormat' => 'yyyy-MM-dd\'T\'HH:mm:ssZZZZZ',
        'clientOptions' => [
            //'inline' => true,
            'minDate' => new \yii\web\JsExpression('new Date("' . $date->format('Y-m-d') . '")'),
            'allowInputToggle' => true,
            'sideBySide' => true,
            'locale' => 'it-IT',
            'disabledDates' => $date_disabled,
            'widgetPositioning' => [
                'horizontal' => 'auto',
                'vertical' => 'auto'
            ],
            //'format' => 'dddd d MMMM YYYY : HH:mm',
            'stepping' => '30',
        ]
    ])`
macrawat commented 7 years ago

In my case $model->date = 2017-06-22 13:19:56 but it is showing 2017-06-27 18:49:56 i.e it is adding +5:30 which is my time zone. How to disable adding timezone before displaying time.?

sokollondon commented 5 years ago

Same problem. Is there a solution?

realmrv commented 4 years ago

Got the same problem. I solved the problem by setting the defaultTimeZone settings in the formatter component in accordance with the settings for the date.timezone parameter in php.ini

        'formatter' => [
            'dateFormat' => 'php:d.m.Y',
            'datetimeFormat' => 'php:d.m.Y H:i:s',
            'timeFormat' => 'php:H:i:s',
            'defaultTimeZone' => 'Europe/Moscow',
            'locale' => 'ru-RU',
            'nullDisplay' => '',
        ],
winternet-studio commented 8 months ago

Got the same problem. I solved the problem by setting the defaultTimeZone settings in the formatter component in accordance with the settings for the date.timezone parameter in php.ini

        'formatter' => [
            'dateFormat' => 'php:d.m.Y',
            'datetimeFormat' => 'php:d.m.Y H:i:s',
            'timeFormat' => 'php:H:i:s',
            'defaultTimeZone' => 'Europe/Moscow',
            'locale' => 'ru-RU',
            'nullDisplay' => '',
        ],

Where do you set this in the widget? Or what is it you are talking about here?

realmrv commented 8 months ago

Where do you set this in the widget? Or what is it you are talking about here?

it's the formatter component's settings inside app configuration https://www.yiiframework.com/doc/guide/2.0/en/structure-applications#components