Cannot get PHP nor JS to work in footer for auto Copyright updating

Copyright © 2006–<?php echo date("Y"); ?>

Does not show the current year.

When put in JS it saves to a blank white page and then vanishes.

<script language="javascript" type="text/javascript">
var today = new Date()
var year = today.getFullYear()
document.write(year)
</script>

  • Nastia

    Hello MSAMike , I trust you are doing well today!

    Unfortunately, the PHP code will not work inside the code element, the Upfront was not build to accept PHPcode.

    Currently, as it seems, there is a bug inside a Code element > Write Custom Code, it doesn't accept any JS code. I had this to our developers so they can have a closer look.

    I had a chat with developers and they provided a different solution. Would you please add the following code inside a Code Element > 3rd party element

    <div id="myElem">starter text</div>
    <script language="javascript" type="text/javascript">
    
    var today = new Date();
    var year = today.getFullYear();
    document.getElementById('myElem').textContent = year;
    </script>

    This code will pull the current date.

    I hope this will help!

    Cheers,
    Nastia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.