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

Related Tutorials..

Bricks Builder Editor Tweaks

Bricks Builder Editor Tweaks

Updated on 19 June 2024 This article is a compilation of some possible editor tweaks that make working with the Bricks builder better. "Better" is…
Categories:
Tags:
Show Product Categories Count Using Bricks Filter Hook

Show Product Categories Count Using Bricks Filter Hook

Unable to find terms count from the Dynamic Data provided by Bricks theme? It's okay, this simple tutorial shows you how to properly get the…
Categories:
Tags:
Pro
“Truncate text to these many characters” Bricks Control

“Truncate text to these many characters” Bricks Control

Bricks provides a :<number> dynamic data tag modifier that can be used to limit the amount of text by the specified number of words. Ex.:…
Setting Active Tab in Bricks’ Tabs (Nestable) Element

Setting Active Tab in Bricks’ Tabs (Nestable) Element

With Bricks' Nestable tab element, here's how we can set which tab is active by default.
Categories:
Pro
How to Insert an Ad or an Element Between Posts in Bricks

How to Insert an Ad or an Element Between Posts in Bricks

How to insert an image or any Bricks element between posts output by a query loop.
Categories:
Tags:
Pro
Nested Queries in Bricks – Posts Grouped by Published Years and Categories

Nested Queries in Bricks – Posts Grouped by Published Years and Categories

In the past we showed how posts could be grouped by years in Bricks. This Pro tutorial takes it further by grouping posts by categories…
Categories:
How to Exclude Elements from Bricks Editor

How to Exclude Elements from Bricks Editor

Bricks has a handy bricks/builder/elements filter using which the available elements that show up after clicking + (or ⌃/⌘ + ⇧ + E) in the…
Categories:
Tags:
Pro
Limit Bricks Users Query to Current Post’s User-type ACF Field Value

Limit Bricks Users Query to Current Post’s User-type ACF Field Value

Consider this scenario with ACF: "John Briley" user: "Gandhi" movie: The requirement is to show John Briley as the author when Gandhi movie item is…
Categories: