different date for one day, (I add screenshot)


in my database a date is saved, but when I display it on the GridView adds one more day, my desire is to display and handle all dates in the format: d-m-Y



Why more than 1 day is added to the actual date in the gridview?

My Yii version:

    "php": ">=5.4.0",

    "yiisoft/yii2": ">=2.0.4",

    "yiisoft/yii2-bootstrap": "*",

    "yiisoft/yii2-swiftmailer": "*",

    "yiisoft/yii2-jui": "^2.0"


Because your timezone is behind UTC?

Set the timezone in your application, to UTC.

como hago eso?

in that file? that I place?

only one change this in php.ini:


; Defines the default timezone used by the date functions

; http://php.net/date.timezone


And what time zone is your database server set to be using?

I suspect that it is only in the evening that you get a days difference?

Are you using TimestampBehavior or other things that uses the expression NOW() to generate timestamps?

That would use the time and timezone of the db server.

I make sure to set the timezone to UTC everywhere. It is easier to work with.

I also never use expressions like NOW() to generate timestamps, it’s too server specific.