Jump to content

ocam

Member
  • Posts

    3
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

ocam's Achievements

Level 1

Level 1 (1/20)

0

Reputation

  1. Hey there, My intention is to change the date format to something like "13 Mar 2022" so I used the two code injections from the thread already shared in the thread by @Beyondspace. I used dateformat = "dd mmm yyyy" and it kinda worked. I get the "invalid date" that @AdamR has, but appears to have fixed? Our blog is here: www.yshousing.org.au/blog I saw some others in the thread had similar troubles? I am based in Australia and Squarespace is set to that location. We use day-month-year. I understand it could be related to that? Any anyone been able to solve it? Thanks for @Beyondspace and @AdamR and others for any suggestions you can make Thanks! Oscar ++ First code I used: <!-- Fix inconsistent blog date format on Squarespace 7.1 template --> <!-- Squarespace Forum Update 06-11-2021 --> <script src="https://stevenlevithan.com/assets/misc/date.format.js"></script> <script> (function(){ document.addEventListener('DOMContentLoaded', function() { const dateformat = "dd mmm yyyy"; const pubdates = document.querySelectorAll("time[datetime]:not([class*=event-time]), time[pubdate], time.blog-meta-item--date"); pubdates.forEach(pubDate => { let d = new Date(pubDate.getAttribute("datetime") || pubDate.innerText); if (pubDate.classList.contains('blog-meta-item--date') ) { d = new Date(document.querySelector('[itemprop="datePublished"]').getAttribute('content').split("T")[0]); } pubDate.innerHTML = d.format(dateformat); }); }); })(); </script> Second code I used <script src="https://momentjs.com/downloads/moment.js"></script> <script> (function(){ document.addEventListener('DOMContentLoaded', function() { const outputDateFormat = "DD MMMM YYYY"; const inputDateFormat = "D/M/YY" const pubdates = document.querySelectorAll(".blog-basic-grid.collection-content-wrapper time[pubdate]"); pubdates.forEach(pubDate => { d = moment(pubDate.innerText,inputDateFormat); pubDate.innerHTML = d.format(outputDateFormat); }); }) })() </script>
×
×
  • 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.