Jump to content

Clock (PHP or ActionScript)


JamesThePanda

Recommended Posts

I have a site and I want a clock on there. The clock has to show the time in Georgia.

I have seen some flash clocks I want to use. but I not sure how to get them to read the time in georgia most use the users clock.

I was thinking of using the time on the server and then readusting but I would like something more realiable. (In case the server settings are changed)

I was thinking is there a link for time around the world. Like maybe some thign in xml I could call thru action script.

Does anyone know of anythign like this?

 

Thanks

 

James

Link to comment
https://forums.phpfreaks.com/topic/110115-clock-php-or-actionscript/
Share on other sites

yer the thing is I dont want it based on my server clock, I would like based on anouther servers clock,

Do you know if there are that could be linked to so no matter what server the site is on it would always stay in georgia time.

 

I was thinking that there might be a site out there that specialise in providing accurate time for sites.

 

 

Thanks

 

James

 

BTW DarkWater I added you on MSN

Or you could use what I use:

 

JAVASCRIPT CODE BIT THINGY DOODAH WHATSIT

<script type="text/javascript">
<!--

function updateClock ( )
{
  var currentTime = new Date ( );

  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  // Compose the string for display
  var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

  // Update the time display
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}

// -->
</script>

 

Then have your body tag as this:

<body onload="updateClock(); setInterval('updateClock()', 1000 )">

 

 

Then where you want your clock:

<?
$today = date("F j, ");
echo $today;
?><span id="clock"> </span>

 

Not my javascript, but this works well for me.

 

Also, if the server is moving (i mean not necessary whichever place it is) and yet the same to be used is the same with whatever they want to assign to it... you may use:

 

Ajax... mentioned earlier

 

OR

 

get the time from that server, and send it together to the client then use JavaScript to update the time... using setInterval(). <-- recommended since (am talkin bout Ajax being unnecessary) you do not need to always communicate to the server just to get the time... too tedious and can be slow.

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.