Timezones

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #550567
    dliciaga
    Participant

    I have conference calls that I am posting events on and need to display the time in several timezones – EST, CST, MST, PST
    How can this be accomplished?

    #558015
    Barry
    Member

    Hi!

    The first thing to do here is take a look at our Themer’s Guide which covers the basics of safely overriding and customizing our templates 🙂

    From there it really depends on where exactly you want to implement this feature – if it’s to occur within actual event posts then you’ll probably be interested in setting up a custom tribe-events/single-event.php template (based on the main views/single-event.php template found in The Events Calendar’s plugin directory).

    Some code like this should allow you to grab the existing time, change the timezone and display the result:

    $starts_on = tribe_get_start_date( null, false, 'Y-m-d H:i:s' );
    $source_tz = 'America/Los_Angeles';
    $target_tz = array( 'America/Edmonton', 'America/New_York' );
    $date_time = new DateTime( $starts_on, new DateTimeZone( $source_tz ) );
    
    foreach ( $target_tz as $new_tz )
    	echo $date_time->setTimezone( new DateTimeZone( $new_tz ) )->format( 'H:i (e)' );

    You might position this just after the loop starts, which in the context of single-event.php is marked be these lines:

    <?php while ( have_posts() ) :  the_post(); ?>
    	<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    This is a relatively advanced customization so it’s something we’ll really need to leave in your hands in terms of ironing out the details – but I hope this gives you a few ideas that will help you to get started.

    Good luck 🙂

    #723612
    Barry
    Member

    Hi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Timezones’ is closed to new replies.