Jump to content

Cirkular

Member
  • Posts

    1
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Cirkular reacted to Romulusmap in Changing the date format of blog posts   
    Hey guys,

    I've been looking for a solution to this problem myself and since I haven't found one, I've come up with my own. It's rather crude but should be efficient, when customized to your own template. Might change with time but just hit me and I'll try to help.
    Inject it into the header and change the classes (if needed) for it to work. It's working after the page loaded so you might get a split second flash of old dates.
    First code is for English users. Just switches  order around. Second one is for international users.
     
    "//Changing blog grid view dates order."
    simply switches the display style from MM/DD/YYYY to DD/MM/YYYY. "//Changing blog detailed view  dates."
    changes language to Polish (or any other if you substitute your own 🙂), as well as switches the order around.  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> //Changing blog grid view dates order. $(document).ready(function() { $('time.blog-date').each(function(){ let dateArray = this.innerText.split("/"); let dateCompiled = dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2]; console.log(dateCompiled); this.innerText = dateCompiled; }); //Changing blog detailed view dates. $('time.blog-meta-item--date').each(function(){ this.innerText = this.innerText.split(" ")[1] + " " + this.innerText.split(" ")[0]; }); }); </script>  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> //Changing blog grid view dates order. $(document).ready(function() { $('time.blog-date').each(function(){ let dateArray = this.innerText.split("/"); let dateCompiled = dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2]; console.log(dateCompiled); this.innerText = dateCompiled; }); //Changing blog detailed view dates. $('time.blog-meta-item--date').each(function(){ if (this.innerText.split(" ")[0] === 'Jan'){ this.innerText = this.innerText.split(" ")[1] + ' Stycznia'; } else if (this.innerText.split(" ")[0] === 'Feb') { this.innerText = this.innerText.split(" ")[1] + ' Lutego'; } else if (this.innerText.split(" ")[0] === 'Mar') { this.innerText = this.innerText.split(" ")[1] + ' Marca'; } else if (this.innerText.split(" ")[0] === 'Apr') { this.innerText = this.innerText.split(" ")[1] + ' Kwietnia'; } else if (this.innerText.split(" ")[0] === 'May') { this.innerText = this.innerText.split(" ")[1] + ' Maja'; } else if (this.innerText.split(" ")[0] === 'June') { this.innerText = this.innerText.split(" ")[1] + ' Czerwca'; } else if (this.innerText.split(" ")[0] === 'July') { this.innerText = this.innerText.split(" ")[1] + ' Lipca'; } else if (this.innerText.split(" ")[0] === 'Aug') { this.innerText = this.innerText.split(" ")[1] + ' Sierpnia'; } else if (this.innerText.split(" ")[0] === 'Sept') { this.innerText = this.innerText.split(" ")[1] + ' Września'; } else if (this.innerText.split(" ")[0] === 'Oct') { this.innerText = this.innerText.split(" ")[1] + ' Października'; } else if (this.innerText.split(" ")[0] === 'Nov') { this.innerText = this.innerText.split(" ")[1] + ' Listopada'; } else if (this.innerText.split(" ")[0] === 'Dec') { this.innerText = this.innerText.split(" ")[1] + ' Grudnia'; } }); }); </script> If anyone needs any help with their template, feel free to ask. I'll try to help. Thanks!
×
×
  • 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.