Jump to content
  • 0

Help on adjusting time?


Talon

Question


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  78
  • Reputation:   1
  • Joined:  09/01/14
  • Last Seen:  

Here's the working live time I got it running on my fluxcp but I'm not sure how to make it 3 minutes slower, perhaps anyone knows it?
 
 

< script type="text/javascript">

function GetClock(){
d = new Date();
dx = d.toGMTString();
dx = dx.substr(0,dx.length -3);
d.setTime(Date.parse(dx))
d.setSeconds(d.getSeconds() + <?php date_default_timezone_set('America/New_York'); echo date('Z'); ?>);
nhour  = d.getHours();
nmin   = d.getMinutes();
nsec   = d.getSeconds();

     if(nhour ==  0) {ap = " AM";nhour = 12;} 
else if(nhour <= 11) {ap = " AM";} 
else if(nhour == 12) {ap = " PM";} 
else if(nhour >= 13) {ap = " PM";nhour -= 12;}

if(nmin <= 9) {nmin = "0" +nmin;}
if(nsec <= 9) {nsec = "0" +nsec;}


document.getElementById('clockbox').innerHTML=""+nhour+":"+nmin+":"+nsec+ap+"";
setTimeout("GetClock()", 1000);
}
window.onload=GetClock;
</script>

Already fixed it, here's the code if anyone wants it 

<script type="text/javascript">
offset = Math.round(new Date().getTime() / 1000);

function GetClock(){
tzOffset = -5;//set this to the number of hours offset from UTC
tzOffset1 = -3;
tzOffset2 = -15;

d = new Date();
dx = d.toGMTString();
dx = dx.substr(0,dx.length -3);
d.setTime(Date.parse(dx))
d.setHours(d.getHours() + tzOffset);
d.setMinutes(d.getMinutes() + tzOffset1);
d.setSeconds(d.getSeconds() + tzOffset2);
nhour  = d.getHours();
nmin   = d.getMinutes();
nsec   = d.getSeconds();

     if(nhour ==  0) {ap = " AM";nhour = 12;} 
else if(nhour <= 11) {ap = " AM";} 
else if(nhour == 12) {ap = " PM";} 
else if(nhour >= 13) {ap = " PM";nhour -= 12;}

if(nmin <= 9) {nmin = "0" +nmin;}
if(nsec <= 9) {nsec = "0" +nsec;}


document.getElementById('clockbox').innerHTML=""+nhour+":"+nmin+":"+nsec+ap+"";
setTimeout("GetClock()", 1000);
}
window.onload=GetClock;
</script>
<div id="clockbox"></div>
Edited by Talon
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

you can just simply adjust your server time, all the website follow the time of your server/vps.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  78
  • Reputation:   1
  • Joined:  09/01/14
  • Last Seen:  

May I know the scripts of it? So it could shorten my codes for faster loading time?   /lv

Edited by Talon
Link to comment
Share on other sites

×
×
  • Create New...