JamesThePanda Posted June 13, 2008 Share Posted June 13, 2008 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 More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 What? Do you want it updated in real time, or updated on page refreshes/accesses? Link to comment https://forums.phpfreaks.com/topic/110115-clock-php-or-actionscript/#findComment-565106 Share on other sites More sharing options...
JamesThePanda Posted June 13, 2008 Author Share Posted June 13, 2008 yes I think it would have to be in real time. Link to comment https://forums.phpfreaks.com/topic/110115-clock-php-or-actionscript/#findComment-565113 Share on other sites More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 Okay. use Javascript then. What time zone is your server in? Link to comment https://forums.phpfreaks.com/topic/110115-clock-php-or-actionscript/#findComment-565117 Share on other sites More sharing options...
JamesThePanda Posted June 13, 2008 Author Share Posted June 13, 2008 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 Link to comment https://forums.phpfreaks.com/topic/110115-clock-php-or-actionscript/#findComment-565125 Share on other sites More sharing options...
kenrbnsn Posted June 13, 2008 Share Posted June 13, 2008 If you want to display the time from the server, you will have to use AJAX to do that. Ken Link to comment https://forums.phpfreaks.com/topic/110115-clock-php-or-actionscript/#findComment-565148 Share on other sites More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 No you don't actually. You can use UTC time and just subtract 5 hours (-5). Link to comment https://forums.phpfreaks.com/topic/110115-clock-php-or-actionscript/#findComment-565155 Share on other sites More sharing options...
marklarah Posted June 14, 2008 Share Posted June 14, 2008 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. Link to comment https://forums.phpfreaks.com/topic/110115-clock-php-or-actionscript/#findComment-565313 Share on other sites More sharing options...
marklarah Posted June 14, 2008 Share Posted June 14, 2008 If you need to change the time zone, just do in the javascript somewhere currentHours = currentHours+1; or whataver Link to comment https://forums.phpfreaks.com/topic/110115-clock-php-or-actionscript/#findComment-565314 Share on other sites More sharing options...
bluejay002 Posted June 14, 2008 Share Posted June 14, 2008 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. Link to comment https://forums.phpfreaks.com/topic/110115-clock-php-or-actionscript/#findComment-565340 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.