Jump to content

Change/ translate date on events page

Recommended Posts

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script><script></script>
<script src="https://momentjs.com/downloads/moment.js"></script>
<script src="https://momentjs.com/downloads/moment-with-locales.js"></script>
<script>
$(document).ready(function() {
    if ($(".event-date").length) {
        var translate = moment($(".event-date").attr("datetime")).locale("SL").format('dddd, MMMM D, YYYY');
        $(".event-date").html(translate);
    
        $(".product-price")
          .contents()
          .filter(function() {
            return this.nodeType == 3;
          }).remove();
    }
});
</script>

Add this to Advanced Code Injection Header if you dont mind use some javascript on your site

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

image.thumb.png.c106a77c00c157b79019e88970d5484c.png

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, 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...
  • 2 weeks later...
  • 1 year later...
On 11/12/2020 at 10:54 AM, bangank36 said:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script><script></script>
<script src="https://momentjs.com/downloads/moment.js"></script>
<script src="https://momentjs.com/downloads/moment-with-locales.js"></script>
<script>
$(document).ready(function() {
    if ($(".event-date").length) {
        var translate = moment($(".event-date").attr("datetime")).locale("SL").format('dddd, MMMM D, YYYY');
        $(".event-date").html(translate);
    
        $(".product-price")
          .contents()
          .filter(function() {
            return this.nodeType == 3;
          }).remove();
    }
});
</script>

Add this to Advanced Code Injection Header if you dont mind use some javascript on your site

Hi @bangank36 Could you please help with the Thai dates? Thank you so much!

Link to comment
11 hours ago, Seanth said:

Hi @bangank36 Could you please help with the Thai dates? Thank you so much!

Kindly change a little my previous code from

locale("SL")

to

locale("th")

About the format of date you can get the reference from:

image.png.da864691c14788a1b154860928fc0037.png

Edited by bangank36

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
  • 4 weeks later...

@bangank36

Thank you for your help, but the code seems to have alter the date to the same date for all events. Please see below. Now sure what happened. I just pasted the code.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://momentjs.com/downloads/moment.js"></script>
<script src="https://momentjs.com/downloads/moment-with-locales.js"></script>
<script>
$(document).ready(function() {
    if ($(".event-date").length) {
        var translate = moment($(".event-date").attr("datetime")).locale("TH").format('dddd, MMMM D, YYYY');
        $(".event-date").html(translate);
    }
});
</script>

image.png.031fa82a61a1fe9ccb1da6c7a853864c.png

Link to comment
On 2/14/2022 at 12:40 PM, KyleNathan said:

Once you click View Event, the time still appears even though I removed it from the previous page. Is there a way to remove it? Thank you!

 

Screen Shot 2022-02-14 at 12.39.51 AM.png

Can you share link to page in screenshot? We can help easier

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

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.