Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.