I've seen several forums ask for a quick and easy way to adapt a date in a CMS collection to a users timezone. This is usually for an event, to make it easy for someone to know what time something is going to be, no matter what timezone they are in.
I've done a video outlining this step by step, but I'm going to also outline the steps here.
Add this custom code as an embed on the page you want to add the custom date and time to:
You'll notice a long ling of red text once you paste the code in. Not to fear, this is exactly what you should be seeing.
Webflow doesn't exactly love that we are using some weird custom code, so it's just trying to inform us that it thinks it looks wrong, but it's not.
We need to replace the "ADD_YOUR_CMS_ELEMENT_NAME" with the name of the Date/Time picker label that we've used. Since we need to get this exactly right, we are going to add in the custom CMS field at the bottom of all our code, and then copy it so we can find the title.
Once you've selected the purple CMS field, we are going to paste it into any text programme so we can see exactly what's inside it.
Though it looks like a bunch of nonsense, the bit that we're looking for is just after the 3rd ", and remember that it will look like something similar to what you called the label back when we set up the Date/Time picker.
In my case, it's start-date-time, so I'm going to copy this and drop it back into our custom code that we added, replacing ADD_YOUR_CMS_ELEMENT_NAME.
If you managed to get through all this custom code and you're not feeling too nauseous, then let's bind the new date and time to the text and test this.
Remember where we added in our text elements? We're going to add classes to this text to tell the code where we want the custom date and time to be displayed.
We're going to add a 'date' class to the date text, and 'time' class to the time text.
Once we've done this, we can publish our site and see the result.
Now our site is changing the date and time live on the page to be adapted to our local time zone.
The last issue to fix is that I set the date and time in New Zealand, but now the time is showing up differently than the time I set in the CMS. We want the time to adapt to my timezone, not a different timezone.
Let's jump back into our custom code and at the end of the red block, change the PDT timezone to ours, which is in this case, GMT+13.
After we have republished and refreshed our page, we can see time is now the time we set in the CMS.
Looks pretty good to me.
To test in other timezones, open up Chrome if you're not already using it, go into dev tools of the website you're testing, and open up the "Sensors" tab under More Tools. Here you can change the timezone and refresh the page to make sure all is looking good.