Pocamuffin Posted October 14, 2021 Posted October 14, 2021 Site URL: http://alextreadway.co.uk/journal Does anyone know how to change the date format on blog pages? Right now it's: Wednesday 10.13.21 I'm in the UK so would be much better like this for example: 13th October 2021 Is there a fix somehow? Thanks Alex
Pocamuffin Posted October 14, 2021 Author Posted October 14, 2021 So after some experimenting with other posts I've solved this. Solution here. Ad this code to settings/advanced/code injection See pic attached shows result <!-- Fix inconsistent blog date format on Squarespace 7.1 template --> <!-- Squarespace Forum 03-08-2021 --> <script src="https://stevenlevithan.com/assets/misc/date.format.js"></script> <script> document.addEventListener('DOMContentLoaded', function() { var dateformat = "dd mmmm yyyy"; var pubdate = document.querySelectorAll("time[datetime], time[pubdate], time.blog-meta-item--date"); for (var i = 0; i < pubdate.length; i++) { var d = new Date(pubdate[i].getAttribute("datetime") || pubdate[i].innerText); if ( pubdate[i].classList.contains('blog-meta-item--date') ) { d = new Date(document.querySelector('[itemprop="datePublished"]').getAttribute("content").split("T")[0]); } pubdate[i].innerHTML = d.format(dateformat); } }); </script> Beyondspace and tuanphan 2
Beyondspace Posted November 7, 2021 Posted November 7, 2021 As additional info, you can edit any other format by editing the line var dateformat = "dd mmmm yyyy" BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </> 🗓️ Delivery Date Picker (Date picker form field) Gallery block 7.1 workaround </> 🤖 Ask me anything
Beyondspace Posted June 26 Posted June 26 Changing inconsistent blog publication date might by tricky, I made a dedicated post for the issue here How to change Squarespace blog date format BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </> 🗓️ Delivery Date Picker (Date picker form field) Gallery block 7.1 workaround </> 🤖 Ask me anything
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment