Dynamic timestamp javascript. How to implement into Webflow site

Hi

I would like to know the correct way to implement the following javascript into a webflow site’s footer div.

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

Its for the timestamp automatically updating eacha and every year.

Thanks
Amreet

The way I implemented this was by creating a text span that would hold the dynamic date and giving it the ID “year”. I then targeted that ID by placing this code in the footer custom code section:

<script type="text/javascript">
  // Get the current year and put it in a variable
  var year = new Date().getFullYear().toString();
  // Write the date into element with ID "year"
  document.getElementById("year").innerHTML = year;
</script>

Hope that helps! :slight_smile:

1 Like