dlthdus0817 Posted April 29, 2021 Share Posted April 29, 2021 Site URL: http://revelucent.com Hi, I want to match the Date Format with the Blog list page and the Blog page. Blog list page has the date with MM/DD/YY. But on the blog page, the date is showing as April DD. Is there any Custom Code for matching the date format as MM/DD/YY for both pages? Thank you so much! Beyondspace 1 Link to comment
Beyondspace Posted May 1, 2021 Share Posted May 1, 2021 On 4/30/2021 at 3:19 AM, dlthdus0817 said: Site URL: http://revelucent.com Hi, I want to match the Date Format with the Blog list page and the Blog page. Blog list page has the date with MM/DD/YY. But on the blog page, the date is showing as April DD. Is there any Custom Code for matching the date format as MM/DD/YY for both pages? Thank you so much! You will need custom javascript for that, check the solution I already provided Blog collection page - move metadata to bottom + reformat date (7.1) - Coding and Customization - Squarespace Forum BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 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
dlthdus0817 Posted May 3, 2021 Author Share Posted May 3, 2021 On 4/30/2021 at 8:07 PM, bangank36 said: You will need custom javascript for that, check the solution I already provided Blog collection page - move metadata to bottom + reformat date (7.1) - Coding and Customization - Squarespace Forum Hi, the date format has been updated successfully by using your css. But, for some reason, the date on blog list and the blog post is different. There is one date gap between two pages. Do you know why it happens? Thank you so much for your help! Beyondspace 1 Link to comment
Beyondspace Posted May 3, 2021 Share Posted May 3, 2021 46 minutes ago, dlthdus0817 said: Hi, the date format has been updated successfully by using your css. But, for some reason, the date on blog list and the blog post is different. There is one date gap between two pages. Do you know why it happens? Thank you so much for your help! that's time zone issue, I thought I fixed it already, let me check again BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 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
Beyondspace Posted May 3, 2021 Share Posted May 3, 2021 1 hour ago, dlthdus0817 said: Hi, the date format has been updated successfully by using your css. But, for some reason, the date on blog list and the blog post is different. There is one date gap between two pages. Do you know why it happens? Thank you so much for your help! Your script is slightly different, could you try this <!-- Squarespace Forum 03-08-2021 --> <script src="https://stevenlevithan.com/assets/misc/date.format.js"></script> <script> document.addEventListener('DOMContentLoaded', function() { var dateformat = "mmm/dd/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> tuanphan 1 BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 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
dlthdus0817 Posted May 3, 2021 Author Share Posted May 3, 2021 1 hour ago, bangank36 said: Your script is slightly different, could you try this <!-- Squarespace Forum 03-08-2021 --> <script src="https://stevenlevithan.com/assets/misc/date.format.js"></script> <script> document.addEventListener('DOMContentLoaded', function() { var dateformat = "mmm/dd/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> Hi, thanks for the quick reply. I changed the code, but still has the same issue. Do you think it's because of the time zone? But how it has the different time date for the same blog post? Beyondspace 1 Link to comment
Beyondspace Posted May 5, 2021 Share Posted May 5, 2021 On 5/4/2021 at 12:44 AM, dlthdus0817 said: Hi, thanks for the quick reply. I changed the code, but still has the same issue. Do you think it's because of the time zone? But how it has the different time date for the same blog post? Timezone is root cause, that why I tried to remove the time in the date string before parsing it BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 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
Beyondspace Posted May 5, 2021 Share Posted May 5, 2021 BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 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
dlthdus0817 Posted May 5, 2021 Author Share Posted May 5, 2021 11 hours ago, bangank36 said: How it can happen? From my end, it still has the one date gap. Link to comment
Beyondspace Posted May 5, 2021 Share Posted May 5, 2021 2 minutes ago, dlthdus0817 said: How it can happen? From my end, it still has the one date gap. Is it the same post? BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 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
dlthdus0817 Posted May 5, 2021 Author Share Posted May 5, 2021 1 minute ago, bangank36 said: Is it the same post? Yes! 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