simonf
07-20-2017, 11:02 AM
Hi
I need to display the date/time in various places on my website page, I have some script that should work but does not for some reason.
I created a fiddle for you to see test etc.
[URL="https://jsfiddle.net/0rbtugjo/3/[/URL]
Script is:
<script type="text/javascript">
function GetClock(){var d=new Date();var nmonth=d.getMonth(),ndate=d.getDate(),nyear=d.getFullYear();var nhour=d.getHours(),nmin=d.getMinutes();if(nmin<=9) nmin="0"+nmin
var obj=document.querySelectorAll('.privclock);for(var i in obj){obj[i].innerHTML=""+ndate+"/"+(nmonth+1)+"/"+nyear+" "+nhour+":"+nmin+"";}
window.onload=function(){GetClock();setInterval(GetClock,1000);}</script>
And basic html is
<div class="privclock"></div>
rgds, Simon
I need to display the date/time in various places on my website page, I have some script that should work but does not for some reason.
I created a fiddle for you to see test etc.
[URL="https://jsfiddle.net/0rbtugjo/3/[/URL]
Script is:
<script type="text/javascript">
function GetClock(){var d=new Date();var nmonth=d.getMonth(),ndate=d.getDate(),nyear=d.getFullYear();var nhour=d.getHours(),nmin=d.getMinutes();if(nmin<=9) nmin="0"+nmin
var obj=document.querySelectorAll('.privclock);for(var i in obj){obj[i].innerHTML=""+ndate+"/"+(nmonth+1)+"/"+nyear+" "+nhour+":"+nmin+"";}
window.onload=function(){GetClock();setInterval(GetClock,1000);}</script>
And basic html is
<div class="privclock"></div>
rgds, Simon