So I need to convert everywhere when displaying data in input fields. There is no framework opportunity to solve this efficiently? If thats true, the only thing I need to do it to make select queries to return in desired time zone or get in UTC (as I currently get) and then convert it with PHP.
Since the conversion usually depends on the application (all users with the same timezone, automatic detection, pre-selected timezone in profile etc.) I’m doing it manually.
If you’ll look at Yii formatters there are methods for it.
Thanks for the answer. Well, that’s fine. defaultTimeZone property is available since 2.0.1. The problem is query.
My table:
event -
id start_time end_time
1 2015-01-01 03:00:00 2015-01-01 04:00:00
2 2015-01-01 14:00:00 2015-01-01 15:00:00
My query looks like this:
SELECT ABS(EXTRACT(EPOCH FROM end_time - start_time))/60 as time_length, start_time at time zone 'America/Chicago' as start_time, end_time at time zone 'America/Chicago' as end_time FROM event
(("start_time" >='2015-01-01 00:00:00' AND "start_time"<='2015-01-01 23:59:59') OR ("end_time">='2015-01-01 00:00:00' AND "end_time"<='2015-01-01-01'))
ORDER BY start_time ASC;
It returns both rows and it should not, because time zone iz America/Chicago. First row started in 2014-12-31.
PS: Its postgreSQL.
EDIT:
How to change time zone dinamically? I have HelperModel and there is something like this:
public static function getTimeZone(){
return "America/Chicago";
// I will get it from db
}