Reputation: 3
What custom code can I add to squarespace to have the full day publish to a blog post? To look like this: WEDNESDAY, APR 29, 2020 on each blog post?
This is what I have currently: APR 29, 2020
<time class="dt-published blog-meta-item blog-meta-item--date" datetime="Apr 28" pubdate="" data-content-field="published-on">
<span>Apr 29, 2020</span>
</time>
Upvotes: 0
Views: 663
Reputation: 699
I believe you are looking for Date method in JavaScript.
Basically I have just inserted each day and month to array of strings and extracted the current date through Date()
function.
var d = new Date();
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
document.getElementById("demo").innerHTML = days[d.getDay()] + " " + months[d.getMonth()] + " " + d.getDate() + " " + d.getFullYear();
<p id="demo"></p>
Upvotes: 0