Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Summary event date, change to UK format


LFyel101

Question

<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

Link to comment

3 answers to this question

Recommended Posts

  • 0
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

Greeting, it's BaNgan from BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Youtube Gallery for Squarespace
If you find my answer fit your need, 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...