Jump to content

Timezone Do Not Display Correctly


lovephp

Recommended Posts

Guys this script when i run on my system do not show the time correctly why? our server machine time is not correct so how do it make it to show the PST MST CST correctly even tho the server machine time is not correct?

 

<html>
<head>
<SCRIPT LANGUAGE="Javascript">

var timerID = null
var timerRunning = false

function startclock(){
  stopclock()
  showtime()
}

function stopclock(){
  if(timerRunning)
  clearTimeout(timerID)
  timerRunning = false
}

function showtime(){
  var now = new Date()
  var hours = now.getUTCHours()
  var minutes = now.getUTCMinutes()
  var seconds = now.getUTCSeconds()

  var utcTime = "" + (hours)
  utcTime  += ((minutes < 10) ? ":0" : ":") + minutes
  utcTime  += ((seconds < 10) ? ":0" : ":") + seconds

  if (hours - 8 < 0) { var pstTime = "" + (hours - 8 + 24) }
  else { var pstTime = "" + (hours -  }
  pstTime  += ((minutes < 10) ? ":0" : ":") + minutes
  pstTime  += ((seconds < 10) ? ":0" : ":") + seconds

  if (hours - 7 < 0) { var mstTime = "" + (hours - 7 + 24) }
  else { var mstTime = "" + (hours - 7) }
  mstTime  += ((minutes < 10) ? ":0" : ":") + minutes
  mstTime  += ((seconds < 10) ? ":0" : ":") + seconds

  if (hours - 6 < 0) { var cstTime = "" + (hours - 6 + 24) }
  else { var cstTime = "" + (hours - 6) }
  cstTime  += ((minutes < 10) ? ":0" : ":") + minutes
  cstTime  += ((seconds < 10) ? ":0" : ":") + seconds

  if (hours - 5 < 0) { var estTime = "" + (hours - 5 + 24) }
  else { var estTime = "" + (hours - 5) }
  estTime  += ((minutes < 10) ? ":0" : ":") + minutes
  estTime  += ((seconds < 10) ? ":0" : ":") + seconds

  document.getElementById("PST").value = pstTime
  document.getElementById("MST").value = mstTime
  document.getElementById("CST").value = cstTime
  document.getElementById("EST").value = estTime
  document.getElementById("UTC").value = utcTime
  timerID = setTimeout("showtime()",1000)
  timerRunning = true
}
</SCRIPT>


<title></title>
</head>
<body>





<center>
<b>PST</b>&nbsp<INPUT TYPE="text" SIZE=11 VALUE ="....Initializing...." id="PST" style="border-style:none;background-color:transparent">
<b>MST</b>&nbsp<INPUT TYPE="text" SIZE=11 VALUE ="....Initializing...." id="MST" style="border-style:none;background-color:transparent">
<b>CST</b>&nbsp<INPUT TYPE="text" SIZE=11 VALUE ="....Initializing...." id="CST" style="border-style:none;background-color:transparent">
<b>EST</b>&nbsp<INPUT TYPE="text" SIZE=11 VALUE ="....Initializing...." id="EST" style="border-style:none;background-color:transparent">
<b>UTC</b>&nbsp<INPUT TYPE="text" SIZE=11 VALUE ="....Initializing...." id="UTC" style="border-style:none;background-color:transparent">
<img src="1px.png" onload="startclock()"></link>
<center>



</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/270462-timezone-do-not-display-correctly/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.