OllieMackJames Posted March 29, 2021 Posted March 29, 2021 In the procache forum I posted about my hanna code solution to show the current date on a page. Posting here so others can use it if needed. Before I used a document.write solution, but google pagespeed gave warnings with that. I use this on salespages where I want the visitor to see the current date. Works great, I use the html below as [[date]] hanna code <p id="date"></p> <script> days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; months = ["Januari","Februari","March","April","May","June","Juli","August","September","October","November","December"]; d = new Date(); datum = '' + days[d.getDay()] +', '+ months[d.getMonth()] + d.getDate() + ', '+ d.getFullYear() + ''; document.getElementById("date").innerHTML = datum; </script> 1
bernhard Posted March 29, 2021 Posted March 29, 2021 Note that when using id="date" you may only use one date on one page. I'm not using HannaCode at all, maybe you can use PHP to generate an unique id? <?php $id = "date_".uniqid(); ?> <p id="<?= $id ?>"></p> ... document.getElementById("<?= $id ?>").innerHTML = datum; 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now