Welcome Guest, Not a member yet? Register   Sign In
Set user timezone using Date helper
#1

[eluser]vaxis[/eluser]
Hi guys,
I need to set timezone for each user in my db(user set his own timezone from config page).
I read Date helper which have the timezone_menu() for creating dropdown UTC timezones and timezones() which returns the number of hours offset from UTC, but how can i get my server utc and set correct user timezone?
I need this because in my current project users can send and receive messages, but if one users lives in US and other in UE the times are completely wrong.

Thanks for help Smile
#2

[eluser]Clooner[/eluser]
to get the server utc use the php date function http://php.net/manual/en/function.date.php
#3

[eluser]WanWizard[/eluser]
Store all times in the database in GMT. When posting data, convert from the users timezone to GMT before inserting it, when displaying information, convert the GMT time from the database to the timezone of the viewer.

Note that CI's timezone support is very simple, it doesn't take daylight savings into account, let alone changes in daylight savings time over the years, or differences between timezones (one could already be on DST, the other one not).




Theme © iAndrew 2016 - Forum software by © MyBB