@cbravobernal Did you use that plugin? Does this work accurately?
@mohsinworld
Well, it doesn’t set the timezone as a WordPress setting but makes all the PHP date and time functions work with the user timezone, set as a cookie.
I’m not 100% sure if it will suit your requirements, feel free to test it in your local or in your development environment!
-
This reply was modified 3 years, 4 months ago by
Carlos Bravo.
-
This reply was modified 3 years, 4 months ago by
Carlos Bravo.
It didn’t work for me. I’ll do some more tests. I would like WordPress to do this by the core system. Thanks
You can use the filter “option_timezone_string” to alter what WP thinks is its timezone. The string can be a time offset like '+02:00'. It needn’t be a name string like “America/Denver”. You’d need some sort of API or data table that returns an appropriate timezone or offset for any given IP. Note that IP geolocation is often not representative of a user’s actual location, so the timezone so returned may not be entirely accurate.
Returning an accurate time is further complicated by daylight/summer time shifts that change on varying dates, if they occur at all. If you are able to use named timezones, I believe the DateTinme object created can account for these shifts, but I’not 100% sure.