Year change automatically for year in the footer

Hi,

How do I have the year change by default with the year changes in the footer of my website?

http://bluelakecreative.webflow.io/
https://preview.webflow.com/preview/bluelakecreative?preview=68cfbfda25786cb12e08e263487bbcaa

Best,

Nathan

1 Like

Hey @nathanphilsteele,

First let’s split that footer text in two parts:

Part 1: “Copyright © "
Part 2: " Blue Lake Creative. All Rights Reserved.”

Now set the footer text to display: inline so they align nicely in one row (you’ll also have to set the footer to text-align: center.)

Drag in an Embed field right in between the two footer text parts, Add this snippet and give the Embed the same class as footer text.

<script type="text/javascript">
  document.write(new Date().getFullYear());
</script>

That should do the trick! It will now refresh the year browser-side, depending on the user’s time settings.
Let me know if you need any help!

5 Likes

Thanks @SidneyOttelohe!

I know waaay too many websites who could use this wonderful code. Awesome, simple guide @SidneyOttelohe

+1

Christopher

1 Like

@ctrav Haha oh man don’t even get me started. :smiley:

@nathanphilsteele You could also use this code you can customize, skip the first few steps and just drag in an Embed.

Copyright &copy; 2015<script>new Date().getFullYear()>2015&&document.write("-"+new Date().getFullYear());</script>, Your Company Details.

Cheers

Hi @SidneyOttelohe,

The correct year is being pulled in like it should which is awesome!

I do have a couple of questions though:

  1. How do you center the footer text?
  2. How do I keep it from getting weird space in between in mobile portrait view?

Best,

Nathan

Hi @nathanphilsteele!

Select your footer section, go to typography and select text align.
For point 2 though, I’m not seeing any weird spaces on mobile, could you elaborate on this?

1 Like

Hi @SidneyOttelohe,

  1. Good to go
  2. screenshot below

Best,

Nathan

Yes that’s not looking smooth at all. :stuck_out_tongue:

Try this:

Delete that footer text and embed,
Drag in a new embed and add this script:

Copyright &copy; 2015<script>new Date().getFullYear()>2015&&document.write("-"+new Date().getFullYear());</script>, Blue Lake Creative. All Rights Reserved.

That should make things a bit easier!

2 Likes

That did it! Good to go! Thanks @SidneyOttelohe!

Best,

Nathan

1 Like

Awesome, glad I could help!