- Advertisement -
To customize Carrington mobile theme with date and time feature that updates in realtime please follow below steps. Putting date andtime on your wordpress theme has become very easy where there are so many args that can call up real time and date just however you want it.
It may not be easy to do this especially if you are not a developer but I have simplified it and provided you with the exact code that I am using on daily4mative.com. With less talk let’s do more action.
Steps to customize Carrington mobile theme with Date and time.
NB: Please note that this works in every theme.
-
- Log in to your cPanel.
- Locate your header.php file
- Inside it scroll to the place you want it to appear and
- finally add below code I provided for you.
<script type=”text/javascript”>
var tday=[“Sunday”,”Monday”,”Tuesday”,”Wednesday”,”Thursday”,
“Friday”,”Saturday”];
var tmonth=[“January”,”February”,”March”,”April”,”May”,”June”,”July”,
“August”,”September”,”October”,”November”,”December”];
function GetClock(){
var d=new Date();
var nday=d.getDay(),nmonth=d.getMonth(),ndate=d.getDate(),
nyear=d.getFullYear();
var nhour=d.getHours(),nmin=d.getMinutes(),nsec=d.getSeconds(),ap;
if(nhour==0){ap=” AM”;nhour=12;}
else if(nhour<12){ap=” AM”;} else if(nhour==12){ap=” PM”;} else if(nhour>12){ap=” PM”;nhour-=12;}
if(nmin<=9) nmin=”0″+nmin;
if(nsec<=9) nsec=”0″+nsec;
var clocktext=”<span style=”font:12pt Arial; color:#fff;”>”+tday[nday]+”, “+tmonth[nmonth]+”
“+ndate+”, “+nyear+”</span> <span style=”font:12pt Arial; color:#fff; background: #3e3; border-radius: 5px;padding: 2px;”>”+nhour+”:”+nmin+”:”+nsec+ap+”</span>”;
document.getElementById(‘clockbox’).innerHTML=clocktext;
}
GetClock();
setInterval(GetClock,1000);
</script>