We are running The Events Calendar on our multisite installation and have encountered a couple of issues related to timezone support:
We have already tried updating to the latest version of The Events Calendar, removed and reinstalled the plugin, and cleared all caches, but the issue still persists.
Could you please assist us in resolving these issues? Proper timezone handling is critical for our event scheduling functionality.
Thank you for your help.
]]>I recently purchased the plugin, and everything is working well except for one issue with how the time is displayed. When I use {{human_date}}
, new posts show as being 5 hours ago instead of the correct time.
My WordPress timezone is set to America/New_York, and I suspect the issue is related to the plugin reading the timestamp in a different format or timezone.
Is there a way to resolve this issue without modifying the plugin code? Any guidance would be greatly appreciated.
Thank you!
]]>On a multisite, I wish to automate copyright year to update at new year. I can make it work on site 1 but not on 2, 3 etc. Then when changing to consider the base time zone for each site to have an accurate switch on each site, I get lost and nothing works.
I am messing with this snippet to do the job:
// Function to return the current year considering the site's timezone
function auto_current_year() {
// Get the site's timezone setting
$timezone = get_option('timezone_string');
// If timezone is set, adjust the time accordingly
if ($timezone) {
date_default_timezone_set($timezone);
}
// Get the current year based on the site's local time
$year = date('Y');
// Reset the time zone to UTC (optional)
date_default_timezone_set('UTC');
return $year;
}
// Function to register the shortcode for a specific site
function register_auto_current_year_shortcode() {
add_shortcode('year', 'auto_current_year');
}
// Register the shortcode for all sites in the network
function multisite_register_year_shortcode() {
if (is_multisite()) {
// Get all sites in the network
global $wpdb;
$sites = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs}");
// Register the shortcode on each site in the network
foreach ($sites as $site) {
// We add a function for each site to register the shortcode
add_action('init', function() use ($site) {
switch_to_blog($site->blog_id);
register_auto_current_year_shortcode();
restore_current_blog();
});
}
} else {
// For single-site installations, register the shortcode immediately
add_action('init', 'register_auto_current_year_shortcode');
}
}
// Hook the function to run when plugins are loaded
add_action('muplugins_loaded', 'multisite_register_year_shortcode');
All help is most appreciated.
Thx
]]>Currently if we set a count-up timer from near past (lower than 12hours) date and time, users with different timezones, will see different results.
As an example let’s consider that we passed 25minutes from targeted dateTime in shortcode:
-then UserA with timeZone +06:30 will see that 00h and 25m passed. (which is correct beacuse we’ve set same timeZone in shortcode attributes).
-but UserB with timeZone +07:00 will see a negative untidy numbers that will be 0 after 5 minute (in this example) and then starts to counting up.
Any suggestion or help is appreciated.
Thank you
// if ( $tz = get_option( 'timezone_string' ) ); date_default_timezone_set( $tz );
// This conditional BREAKS time calcs in all other plugins, causing times to be displayed with a UTC
// offset from current time zone, BUT commenting this line out breaks THIS plugin, so
// we need to save the current TZ, let this plug do it's time calcs, then restore
// the original TZ.
//
// ************ MOD: ****************
// Try a new way: Read comments
if ($tz = get_option('timezone_string')) { // get WP TZ. If set
$tztemp = date('e'); // save current server TZ
date_default_timezone_set($tz); // set TZ to WP TZ
}
// ************ END *****************
// get the current time
$tnow = intval( date( 'Hi' ) ); // 24-hr with leading zeros: 08:05
// get the week day (today)
$twday = intval( date( 'w' ) ) + 1;
// get the week day (yesterday)
$twyes = ( ( $twday + 6 ) % 8 ) + 1;
// ************ MOD: Set TZ back to original *************
date_default_timezone_set($tztemp);
// ************ END *****************
]]>Another example would be how the upcoming date is shown “2:00 pm GMT – 4:00 pm EDT, October 2, 2024″ it should be “2:00 pm EDT – 4:00 pm EDT, October 2, 2024″
]]>