LFyel101 Posted September 6, 2021 Posted September 6, 2021 <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
tuanphan Posted September 8, 2021 Posted September 8, 2021 Hi, Can you duplicate the page & don't add code there. We can compared 2 pages & check easier? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
LFyel101 Posted September 8, 2021 Author Posted September 8, 2021 Hi @tuanphan, Its injected into the site header but I can remove so you can have a proper look! thank you!
Beyondspace Posted September 27, 2021 Posted September 27, 2021 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 You got it solve somehow BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox - PDF Lightbox popup - ...) </> 🗓️ Delivery Date Picker (Date picker form field) Gallery block 7.1 workaround </> No-code customisations for Squarespace
Recommended Posts
Archived
This topic is now archived and is closed to further replies.