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

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

image.thumb.png.c106a77c00c157b79019e88970d5484c.png

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...
  • 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

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 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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 1 year later...
On 11/12/2020 at 4:54 AM, Beyondspace 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

I tried this for my 7.1 site and it doesn't seem to work. Do you know of any adjustments that can be made so that it works?

https://www.drustvovec.si/tabori-in-aktivnosti/english-camp-radovljica

Link to comment
On 2/2/2024 at 8:57 PM, hansiel said:

I tried this for my 7.1 site and it doesn't seem to work. Do you know of any adjustments that can be made so that it works?

https://www.drustvovec.si/tabori-in-aktivnosti/english-camp-radovljica

Did you solve? I see you added some code with ChatGPT

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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

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.