Jump to content

Summary event date, change to UK format

Recommended Posts

<script>
 // Changes the format of date on summary items
 var myObj = document.getElementsByClassName('summary-metadata-item--date');
 var options = {  year: 'numeric', month: 'long', day: 'numeric'};
 for (var i = 0; i < myObj.length; ++i) {
     var item = myObj[i];  
     var date = new Date(item.innerHTML);
      item.innerHTML = date.toLocaleDateString('en-GB', options);
 }      
 </script>

Hi Folks, 

Wondering if anyone can help, I've used the above code to get UK format dates on my summary blocks for events, but this doesn't work with events that have a date range rather than a single date. Wondering if anyone can help me get it working as its beyond my JS skills! It just shows "invalid date" for thumbnails that have an event spanning more than one date

Any advice appreciated

1956822755_Screenshot2021-09-06at12_35_29.png.6ac4464c88179f80c4e1301d65de0f77.png2023164349_Screenshot2021-09-06at12_35_27.png.79bbb70065cba09f0b999f9ee0c699e9.png

Edited by LFyel101
Link to comment
  • 3 weeks later...
On 9/6/2021 at 6:37 PM, LFyel101 said:
<script>
 // Changes the format of date on summary items
 var myObj = document.getElementsByClassName('summary-metadata-item--date');
 var options = {  year: 'numeric', month: 'long', day: 'numeric'};
 for (var i = 0; i < myObj.length; ++i) {
     var item = myObj[i];  
     var date = new Date(item.innerHTML);
      item.innerHTML = date.toLocaleDateString('en-GB', options);
 }      
 </script>

Hi Folks, 

Wondering if anyone can help, I've used the above code to get UK format dates on my summary blocks for events, but this doesn't work with events that have a date range rather than a single date. Wondering if anyone can help me get it working as its beyond my JS skills! It just shows "invalid date" for thumbnails that have an event spanning more than one date

https://ellipse-krill-97td.squarespace.com/

pw: CG

Any advice appreciated

1956822755_Screenshot2021-09-06at12_35_29.png.6ac4464c88179f80c4e1301d65de0f77.png2023164349_Screenshot2021-09-06at12_35_27.png.79bbb70065cba09f0b999f9ee0c699e9.png

You got it solve somehow

image.thumb.png.bcbf5cf5567520518a58b86ff8805ca0.png

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.