Get Involved
No items added to cart
Home
Discover
Hire
VIEW DEMO
In order to do this, you need to add the “Timezone” field to that post type. That is required to make it work. Then perform the following:
function display_datetime_with_timezone($atts) { $atts = shortcode_atts(array('id' => get_the_ID()), $atts); $post_id = $atts['id']; $timezone = get_post_meta($post_id, 'timezone', true); if (empty($timezone) || !in_array($timezone, timezone_identifiers_list())) { return 'Invalid or undefined timezone for this post.'; } try { $datetimezone = new DateTimeZone($timezone); $datetime = new DateTime('now', $datetimezone); return $datetime->format('g:i A'); } catch (Exception $e) { return 'Error retrieving date and time: ' . $e->getMessage(); } } add_shortcode('user_time', 'display_datetime_with_timezone');
Are you sure you want to exit? Your current conversation will be lost.