{REQ} Eatsern Time Clock

Status
Not open for further replies.

SEÑOR

The Guy Everyone Hates
Messages
4,638
Reaction score
0
Points
0
Hello,

I need a script that shows the current time in (GMT -5:00)Eastern Time for my site. I need it In if possible html/Javascript but php will do if it has to. Nothing to complicated just an example of how I want:

Monday April 16, 6:49 PM

Im offering 300 points., If more is needed, I will offer.
 

SEÑOR

The Guy Everyone Hates
Messages
4,638
Reaction score
0
Points
0
How does it work? BTW thta time is wrong, its 8:16 it says 7:16
 
Last edited:

Christopher

Retired
Messages
14,659
Reaction score
8
Points
0
Change var TimezoneOffset = -5 to var TimezoneOffset = -4.
I'm guessing it has something to do with DST. And if you want the date, I'm working on getting it in there also.

Put in header:
Code:
<SCRIPT Language="JavaScript">
<!-- hide from old browsers
function jsClockTimeZone(){
  // Copyright 1999 - 2001 by Ray Stott
  // OK to use if this copyright is included
  // Script available at http://www.crays.com/jsc
  var TimezoneOffset = -4  // adjust for time zone
  var localTime = new Date()
  var ms = localTime.getTime() 
             + (localTime.getTimezoneOffset() * 60000)
             + TimezoneOffset * 3600000
  var time =  new Date(ms) 
  var hour = time.getHours() 
  var minute = time.getMinutes()
  var second = time.getSeconds()
  var temp = "" + ((hour > 12) ? hour - 12 : hour)
  if(hour==0) temp = "12"
  if(temp.length==1) temp = " " + temp
  temp += ((minute < 10) ? ":0" : ":") + minute
  temp += ((second < 10) ? ":0" : ":") + second
  temp += (hour >= 12) ? " PM" : " AM"
  document.clockFormTimeZone.digits.value = temp
  setTimeout("jsClockTimeZone()",1000)
  }
//-->
</SCRIPT>

Put in body
Code:
<BODY ONLOAD="jsClockTimeZone()">


<FORM NAME="clockFormTimeZone">
<FONT face="Courier New,Courier" size=4>
<INPUT TYPE="text" NAME="digits" SIZE=11 VALUE="Loading">
US Eastern Time
</FONT>
</FORM>

Below is the body to use to include the date:
Code:
<BODY ONLOAD="jsClockTimeZone()">


<FORM NAME="clockFormTimeZone">
<FONT face="Courier New,Courier" size=4>
<script language="Javascript">
<!--
/*
Today's date script
Visit java-scripts.net or 
http://wsabstract.com for this script
*/

 var dayName = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")

 var monName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")

 var now = new Date

 document.write( dayName[now.getDay()] + " " + monName[now.getMonth()] + " "+now.getDate() +",")

//-->
</script>
<INPUT TYPE="text" NAME="digits" SIZE=11 VALUE="Loading">

</FONT>
</FORM>
 
Last edited:

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
I'm guessing it has something to do with DST.
Might have something to do with x10's timezone as well - if x10 was in the eastern time zone, you wouldn't need to adjust the time zone to display it in eastern. Had that glitch with the times on my site as well (to get it synced up with where I am, it's -1 if I'm remembering it right). Other webhosts had it as -2, +1, all depending where they were.
 

SEÑOR

The Guy Everyone Hates
Messages
4,638
Reaction score
0
Points
0
Can you somehow you cna make it, outside of the box, just text?
 

Christopher

Retired
Messages
14,659
Reaction score
8
Points
0
I've been trying, but can't figure it out. I think that you would have to use a document.write command, but I'm not sure how.
 

Chris Z

Active Member
Messages
5,603
Reaction score
0
Points
36
PHP:
<?php
$date = date('h:iA', time()+3600);
echo($date);
?>
:)
 
Last edited:

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
Use

PHP:
<?php

date_default_timezone_set("EST");

echo date("h:iA");

?>
</span></span>
 
Status
Not open for further replies.
Top