wardog
(Icristianrc)
December 5, 2015, 4:58am
1
Hi
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
6839
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"
jacmoe
(Jacob Moen)
December 5, 2015, 4:14pm
3
Because your timezone is behind UTC?
Set the timezone in your application, to UTC.
wardog
(Icristianrc)
December 5, 2015, 5:37pm
4
como hago eso?
in that file? that I place?
only one change this in php.ini:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone=America/Lima
jacmoe
(Jacob Moen)
December 5, 2015, 5:52pm
5
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?
jacmoe
(Jacob Moen)
December 5, 2015, 6:01pm
6
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.