Events and Displaying Timezones

Support for the WordPress Calendar plugin
lexhair
Posts: 32
Joined: Tue Feb 09, 2010 7:03 pm
Location: NYC, USA
Contact:

Events and Displaying Timezones

Unread post by lexhair » Thu May 02, 2019 5:49 pm

I know timezones can be tricky between UTC, the server timezone and the user time zone in the WordPress environment. One of the timezone quirks I came across using this fabulous plug in showed up in my preferred monthly page of the calendar. Mousing over an event with a Start Time displayed everything properly except for the timezone in my case. When I enter a time in my calendar, I always use the local timezone, in my case 'America/New_York'. The Time Format option in WordPress is 'g:i A T' which shows the timezone as T. In the base install of Calendar (v 1.3.13), the functions that output the time were showing UTC in the formatted output rather than the correct EDT.

Without playing around too much with the base install, I put a

Code: Select all

do_action("calendar_set_timezone")
function in the functions that output the formatted event time. In my theme's functions.php file, I hook in to this tag with a function that fires the date_default_timezone_set() function. I've attached a zip for consideration to build into the next release.

There is probably a way to handle this without user intervention but it seems there is so much variability on how WordPress users set up their timezone configuration. I figured an action hook won't interfere with how the plugin works but in cases where the format needs to be manipulated, each install can be customized with the additional action hooks.
Attachments
patch.zip
patch file for timezone output formatting
(46.16 KiB) Downloaded 5 times

User avatar
Kieran
Posts: 2058
Joined: Sat May 26, 2007 1:55 pm
Location: London
Contact:

Re: Events and Displaying Timezones

Unread post by Kieran » Sat May 11, 2019 9:49 pm

Thanks for the info and the patch - time zones are indeed tricky.

I feel there is a chance we can solve it properly if I setup the scenario properly; I'll try and setup my test environment with a non UTC zone on the server and your zone on the WordPress admin and see what I can come up with.

lexhair
Posts: 32
Joined: Tue Feb 09, 2010 7:03 pm
Location: NYC, USA
Contact:

Re: Events and Displaying Timezones

Unread post by lexhair » Mon May 13, 2019 1:46 pm

Thanks. I started playing around with

Code: Select all

get_option('timezone_string')
a bit but I'm not sure this will be set for every user. I've got it set in my environment but I'm not completely sure it's a universal option.

User avatar
Kieran
Posts: 2058
Joined: Sat May 26, 2007 1:55 pm
Location: London
Contact:

Re: Events and Displaying Timezones

Unread post by Kieran » Sun May 19, 2019 9:05 pm

I think the key may indeed lie there; I can always add a check in the plugin to see if that is set and flag a warning on the dash with a link to fix it, stating that Calendar needs it to function properly. I can then implement a solution the depends on that setting being there. Will try a few things out and see where I end up.

Post Reply