Jump to content

Can the year be added to the display of the published date?

Go to solution Solved by Beyondspace,

Recommended Posts

I would have expected perhaps a global setting for how dates are displayed so that they are consistent across the site. But reading the referenced post, I see that is not the way. My use, right now, is for blog listings and blog posts.

https://lion-terrier-9jys.squarespace.com/photography/moving-pictures

Password: catdog

I am running Version 7.1, but hope not to have to pay for a business account to get blog dates.

Edited by BobRockefeller
Link to comment
  • 1 month later...
On 3/25/2023 at 6:10 AM, BobRockefeller said:

I would have expected perhaps a global setting for how dates are displayed so that they are consistent across the site. But reading the referenced post, I see that is not the way. My use, right now, is for blog listings and blog posts.

https://lion-terrier-9jys.squarespace.com/photography/moving-pictures

Password: catdog

I am running Version 7.1, but hope not to have to pay for a business account to get blog dates.

Your site is deleted?

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
  • Solution
19 hours ago, BobRockefeller said:

Rolled over to www.bobrockefeller.com.

Since you site is US based, I chose the date format "mm-dd-yyyy"

Check the snippet on snapshot mode of your site here

The snippet is originated from https://forum.squarespace.com/topic/207841-freeshare-date-display-format-options-on-all-pages/#comment-506718

<!-- 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 = "mm-dd-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>

image.thumb.png.c2e643c33adc7ea478c1ad4fe57e4913.png

image.thumb.png.9a64551138cc2805444d68ed9b010c6f.png

Edited by Beyondspace

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
  • 2 weeks later...

@BobRockefeller There is update to the script where you can choose different date format on the live editor

More info

 

 

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, 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...

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.