Kibit Posted October 4, 2008 Share Posted October 4, 2008 Can anyone tell me what I need to add where in the following JavaScript to add +6 Hours onto the time It displays please... <script type="text/javascript"> var currenttime = '<? print date("F d, Y H:i:s", time())?>' var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December") var serverdate=new Date(currenttime) function padlength(what){ var output=(what.toString().length==1)? "0"+what : what return output } function displaytime(){ serverdate.setSeconds(serverdate.getSeconds()+1) var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear() var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds()) document.getElementById("servertime").innerHTML=datestring+" "+timestring } window.onload=function(){ setInterval("displaytime()", 1000) } </script> <p><b>Current Server Time (+6 hours):</b> <span id="servertime"></span></p> Link to comment https://forums.phpfreaks.com/topic/127009-how-to-add-6-hour-time-offset-in-this-script/ Share on other sites More sharing options...
ngreenwood6 Posted October 4, 2008 Share Posted October 4, 2008 You could try something like this: var hours=new Date(hour); var currenthours = date+6; You will have to make different variables for the hour, mins and seconds. then when you want to display it you would display it like: var time = hours+":"+mins+":"+secs; hope this helps Link to comment https://forums.phpfreaks.com/topic/127009-how-to-add-6-hour-time-offset-in-this-script/#findComment-657242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.