Jump to content

[FreeShare] Date display format options on all pages

Recommended Posts

5 hours ago, creedon said:

Let us know how it goes.

 

Hi @creedon, thanks you so much for taking the time to think about this, I appreciate it.

There's still one inconsistency on the blog page. I've now got dd-m-yyyy throughout (summary block, posts) but the first post on the blog page has dd-mm-yyyy and the other 3 have dd/mm/yyyy. Weird huh?

Edit: I've tried updating dateformat to dd mmmm yyyy, and there's still an inconsistency going on with the blog page. Tried changing date of that post to 11 April (to see if the single digit might be the issue, the others are all 2 digit dates), and that had it change to 4 November on the blog page (11 April on summary block/blog post), so it is confused!

 

Screenshot 2022-04-26 at 09.20.48.png

Edited by JoelleM
Added more info
Link to comment
6 hours ago, JoelleM said:

Hi @creedon, thanks you so much for taking the time to think about this, I appreciate it.

There's still one inconsistency on the blog page. I've now got dd-m-yyyy throughout (summary block, posts) but the first post on the blog page has dd-mm-yyyy and the other 3 have dd/mm/yyyy. Weird huh?

Edit: I've tried updating dateformat to dd mmmm yyyy, and there's still an inconsistency going on with the blog page. Tried changing date of that post to 11 April (to see if the single digit might be the issue, the others are all 2 digit dates), and that had it change to 4 November on the blog page (11 April on summary block/blog post), so it is confused!

 

Screenshot 2022-04-26 at 09.20.48.png

I can not see the custom code on the source. Have you added it to your site?

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
4 minutes ago, bangank36 said:

I can not see the custom code on the source. Have you added it to your site?

I took it off as it wasn't working right. I'll add it back - used your code with dd mmmm yyyy dateformat, then tried @creedon's above, but in both cases it was not affecting all posts on the blog page.

I'll pop it back on now so you can see.
Edit:  now done.

Edited by JoelleM
update
Link to comment
19 hours ago, ChiroUp said:

Hi there, I tried using this code on my site: https://chiroup.com It worked however it's a day off on each publication date if you look at the blog post and then on the blog home page. The dates don't match. They are off by one day. Please help. 

Have you figured it out? Can you share the direct link to the page that gets issue? I can not not find it

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
1 minute ago, JoelleM said:

I took it off as it wasn't working right. I'll add it back - used your code with dd mmmm yyyy dateformat, then tried @creedon's above, but in both cases it was not affecting all posts on the blog page.

I'll pop it back on now so you can see.

You can duplicate the current page and add my custom code only in this page via page setting. Then give me the link to the testing page so It won't effect to other pages

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 minutes ago, bangank36 said:

You can duplicate the current page and add my custom code only in this page via page setting. Then give me the link to the testing page so It won't effect to other pages

It doesn't let me duplicate it since its a blog page maybe, only the posts? I don't mind faffing with it, it's not live yet.

I've added it to code injection only on this page now instead of in site settings: https://together-learning-trust-new.squarespace.com/news-views 

Thanks for looking, I appreciate it.

Link to comment
9 hours ago, JoelleM said:

It doesn't let me duplicate it since its a blog page maybe, only the posts? I don't mind faffing with it, it's not live yet.

I've added it to code injection only on this page now instead of in site settings: https://together-learning-trust-new.squarespace.com/news-views 

Thanks for looking, I appreciate it.

I think your template and locale settings are not compatible with the snippet, do you mind if I pm you for further discussion

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
16 hours ago, JoelleM said:

There's still one inconsistency on the blog page. I've now got dd-m-yyyy throughout (summary block, posts) but the first post on the blog page has dd-mm-yyyy and the other 3 have dd/mm/yyyy.

Did you set the monthFirst constant to false?

This is what I see without any code running.

1952039263_ScreenShot2022-04-26at6_04_35PM.thumb.png.2080137d031c55ac9b9c40b32ad072af.png

Here is what I see with the code and my additions.

1790959326_ScreenShot2022-04-26at6_10_35PM.thumb.png.6c84071bd5cc2bf897dce5f7f0f74713.png

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment

@creedon your modification will only solve an edge case and it probably won't work with a different date format, but it will work if @JoelleM checks it is okay with this. The root cause of this issue is regarding localization date format and will need more time to invest

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
9 minutes ago, bangank36 said:

your modification will only solve an edge case and it probably won't work with a different date format

Agreed. My additions were to help JolleM and anyone who might be in her exact situation. They are not meant to address all date issue problems.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment
  • 1 month later...
  • 1 month later...

Hi there!

I'm facing the same problem as many others... Dates are displaying one day off. Have you guys found any solution yet?

I've deleted the code for now, but I'm looking forward to adjust all dates across the site, specially for events and blog pages.

Link to comment
On 7/15/2022 at 4:07 AM, g-souza said:

Hi there!

I'm facing the same problem as many others... Dates are displaying one day off. Have you guys found any solution yet?

I've deleted the code for now, but I'm looking forward to adjust all dates across the site, specially for events and blog pages.

Can you share your site?

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
On 7/15/2022 at 11:03 PM, bangank36 said:

Can you share your site?

Hi @bangank36.

Sure:
https://sawfish-lute-xb5x.squarespace.com/
password: central2022

I put the code back so you can take a look. Please check the pages:
https://sawfish-lute-xb5x.squarespace.com/exposicoes (events)
https://sawfish-lute-xb5x.squarespace.com/noticias (blog)

I'm attaching some screenshots from these pages without the code, so you can see how dates are jumping back one day.

I also noticed this code is not affecting summary blocks, which I'm using in different pages across the site.

Any help is much appreciated.

Screen Shot 2022-07-21 at 11.47.29.png

Screen Shot 2022-07-21 at 11.59.02.png

Link to comment
11 hours ago, g-souza said:

Hi @bangank36.

Sure:
https://sawfish-lute-xb5x.squarespace.com/
password: central2022

I put the code back so you can take a look. Please check the pages:
https://sawfish-lute-xb5x.squarespace.com/exposicoes (events)
https://sawfish-lute-xb5x.squarespace.com/noticias (blog)

I'm attaching some screenshots from these pages without the code, so you can see how dates are jumping back one day.

I also noticed this code is not affecting summary blocks, which I'm using in different pages across the site.

Any help is much appreciated.

Screen Shot 2022-07-21 at 11.47.29.png

Screen Shot 2022-07-21 at 11.59.02.png

I will check and reply you soon

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
  • 1 month later...

Hey @bangank 36, I use the code above I wasn't sure if it should go in the code injection for header, footer or somewhere else. I put it in header but all my blog posts still say the date in this format: APR 15. I am trying to get the date in this format: April, 15, 2022. This is the code I put in the code injection header. Any help would be greatly appreciated. Thank you,

 

the website URL right now is https://friendsofthechildrenofvnzla.squarespace.com/

 

<!-- 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 = "mmm 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>

Link to comment
  • 2 weeks later...
1 hour ago, paulpants said:

Anyone solve the issue with the blog page meta date and the blog post meta dates being a day off? Running into this same issue @bangank36. Region is US New York, language set to US English. Thanks...

Can you share your site so I can take a look?

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...
  • 4 weeks later...

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.