31st Oct '24
/
0 comments

Event Date and Time in Visitor’s Timezone

In the BricksLabs Facebook group a user asks:

Wondering if you have a way of displaying events in the users time zone in Bricks? The event would be a Metabox CPT.

This Pro tutorial provides the steps for showing the value of a Meta Box datetime type of custom field in visitor's timezone.

For example, let's say an event's date and time has been set to 2024-10-31 10:30 with the WordPress site's timezone set to Melbourne, Australia. When viewed from Melbourne, Australia, that event's single page shows October 31, 2024 at 10:30 AM. When a visitor from NY, USA views the same page they would see October 31, 2024 at 7:30 PM.

Step 1

At Settings → General, set your business/site timezone city.

Step 2

Create your CPT and a corresponding field group with Meta Box.

Do NOT set the value to be saved as timestamp.

Create/edit your CPT posts and populate the field.

Step 3

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 630 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

ACF Checkbox Items with Custom SVG Bullets in Bricks

ACF Checkbox Items with Custom SVG Bullets in Bricks

We walk through outputting list items with SVG icons based on the choice of a ACF Checkbox field.
Categories:
Tags:
Pro
Bricks Forms + Meta Box: Auto-Create Post Relationships on Form Submission

Bricks Forms + Meta Box: Auto-Create Post Relationships on Form Submission

How to link a Bricks post-creation form on a post to a newly created post of another post type using Meta Box relationship.
Pro
Button-specific HTML in Bricks Popup

Button-specific HTML in Bricks Popup

In the Bricks Facebook group a user asks: I need to create popups to expend the text (eg. read more). I wonder if I have…
Categories:
Pro
Redirecting Based on User ID(s) in Post Meta

Redirecting Based on User ID(s) in Post Meta

This Pro tutorial provides the steps to redirect single post pages to a specific URL/location like the site's homepage if the user viewing the page…
JetEngine Term Image in Bricks

JetEngine Term Image in Bricks

How to retrieve the URL of a Media type of a JetEngine custom field attached to a taxonomy term.
Categories:
Tags:
Pro
WooCommerce Product Carousel in Bricks

WooCommerce Product Carousel in Bricks

How to set up a carousel that shows WooCommerce products with the product title, price and Add to Cart button for each.
Categories: