ChiroUp Posted February 25, 2022 Share Posted February 25, 2022 Site URL: https://chiroup.com Hi there, I am wanting to add the year to ALL of my blog posts, currently they only show up as "Feb 18". Is there a settings or some code I can add to show the year? Thanks! Link to comment
lillian6 Posted February 25, 2022 Share Posted February 25, 2022 The current date format in my blog posts is "Feb 24" and I would like it to include the year. Any advice on how to do this? Link to comment
tuanphan Posted February 27, 2022 Share Posted February 27, 2022 See this post 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!) Link to comment
ChiroUp Posted March 2, 2022 Author Share Posted March 2, 2022 On 2/27/2022 at 2:39 AM, tuanphan said: See this post Hi there, I tried to use this code but it did not work: <!-- 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 = "mm-dd-yyyy"; var pubdate = document.querySelectorAll("time[datetime]:not([class*=event-time]), 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]).getAttribute("content"); } pubdate[i].innerHTML = d.format(dateformat); } }); </script> Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment