Welcome Guest, Not a member yet? Register   Sign In
gmt_to_local daylight savings strategy
#1

[eluser]someoneinomaha[/eluser]
I'm working on an app that requires storing and displaying dates and times. My plan is to store all dates and times as GMT and then convert them back to the user using the built-in gmt_to_local function in the date helper.

If I set daylight savings to false, accurate times are displayed to the users for today. However, when daylight savings comes back into effect, entries will appear to be off.

If I go back into the code and change it to be true, the recent entries will be correct again, but if someone reviews older entries, they will be off an hour.

I'm not really sure this is a problem with my app, but I wanted to know how others handled this scenario. Or if I'm just completely misunderstanding how daylight savings fits into this picture.

I noticed a few posts about daylight savings in the forum, but they were either not answered or weren't related to this issue (that I could find).

Anyway, thanks for your time.
#2

[eluser]internut[/eluser]
bump....

I last did a crazy way of going about using GMT and the local time zone setting of a user (or the users timezone for a app to be distributed).

It went well just still not sure if I'm handling dates correctly.

My server is an hour ahead of me and I want to see my time. Though if someone that was on a server 3 hours ahead have a setting to make this work.

Feel like many where I have beat this issue to death.
#3

[eluser]WanWizard[/eluser]
The standard CI date functions are quite useless due to the fixed DST parameter.

Have a look at our date_helper extension. Our version of gmt_to_local always returns the correct local time, without using the DST parameter. Instead it relies on PHP's DateTimeZone class. For PHP version prior to 5.2.0, you need the timezone_helper as well, which emulates the functions of the class, but requires lots of memory. It also provides a replacement for CI's timezone_menu(), to return all possible timezones by region.




Theme © iAndrew 2016 - Forum software by © MyBB