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 613 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Post Title at a Different Location on Image Hover

Post Title at a Different Location on Image Hover

This Pro tutorial provides the steps to update the text of a sticky div with the title of the post that is hovered on the…
Categories:
Sticky Header in Bricks

Sticky Header in Bricks

Updated on 15 Nov 2022 Bricks has a handy sticky feature that enables us to build two types of sticky headers: Also, we can specify…
Categories:
How to Change Bricks Preloader Background Color

How to Change Bricks Preloader Background Color

Working on a dark-themed site like our friend Storm and getting blinded by the light background of Bricks' preloader screen of the editor? Here's how…
Categories:
Opening Bricks Offcanvas with a Custom Link or Button or Div

Opening Bricks Offcanvas with a Custom Link or Button or Div

You may want to trigger the Offcanvas with an element other than the toggle. Here's how to do it.
Categories:
Tags:
Pro
JetEngine Field Value(s) and Label(s)

JetEngine Field Value(s) and Label(s)

A few users in the Bricks forum wanted to know how to retrieve the label that corresponds with the selected value when the type of…
Categories:
Tags:
Pro
Meta Box Date Field Value Custom Format in Bricks

Meta Box Date Field Value Custom Format in Bricks

Updated on 3 Apr 2024 Note: A custom function is no longer needed. Use the date format filter, as mentioned in the Bricks documentation. Ex.:…
Categories:
Tags:
Pro
Masonry for Query Loop in Bricks

Masonry for Query Loop in Bricks

If you are looking to implement masonry with a 'view more' button i.e., click-type of infinite scroll follow this tutorial instead. Updated on 15 Mar…
Categories: