Skip to content

Instantly share code, notes, and snippets.

@jesseeproductions
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save jesseeproductions/e6aead398e6ffab51a98 to your computer and use it in GitHub Desktop.

Select an option

Save jesseeproductions/e6aead398e6ffab51a98 to your computer and use it in GitHub Desktop.
Show End Times for Event and Current GMT Time - The Events Calendar
/* Show End Times for Event and Current GMT Time - The Events Calendar
* *3.9
*
*/
$gmt_offset = ( get_option( 'gmt_offset' ) >= '0' ) ? ' +' . get_option( 'gmt_offset' ) : " " . get_option( 'gmt_offset' );
$gmt_offset = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $gmt_offset );
echo "gmt offset: " . $gmt_offset . "<br>";
echo "event end time actual: " . tribe_get_end_date( $post, false, 'Y-m-d G:i' ) . "<br>";
$ts = strtotime( tribe_get_end_date( $post, false, 'Y-m-d G:i' ) . $gmt_offset );
$date = new DateTime("@$ts");
echo "event end time with offset (+5 from actual endtime): " . $date->format('U = Y-m-d H:i:s') ."<br>";
$ts = time();
$date = new DateTime("@$ts");
echo "current time GMT (+5 from east coast): " . $date->format('U = Y-m-d H:i:s') ."<br>";
@AlexeyGonchar

Copy link
Copy Markdown

Hi there!

Would you tell me please where should it be inserted to work well?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment