live_ex3me Posted August 28, 2007 Share Posted August 28, 2007 Hi there, i have this little script to show me the local time in those cities.. $now = time(); $tz = getenv("TZ"); putenv("TZ=Europe/Bucharest"); printf("<tr> <td valign=middle width=100><font class=text><b>Bucuresti</b> :</td> <td valign=middle width=100 align=center><font class=text><b>%s</b></td><tr>", date('H:i:s', $now)); print '</table>'; how can i make time change each second ? whitout refreshing the page.. Quote Link to comment https://forums.phpfreaks.com/topic/67015-local-time-script-issue/ Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 Use AJAX, Frames, javascript.. nothing thats PHP based really.. Quote Link to comment https://forums.phpfreaks.com/topic/67015-local-time-script-issue/#findComment-336064 Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 Maybe this will help (untested) <script language="javascript"> function TheDay() { Stamp = new Date(); document.write('' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getYear() + ' <br> '); var Hours; var Mins; var Time; Hours = Stamp.getHours(); if (Hours >= 12) { Time = " P.M."; } else { Time = " A.M."; } if (Hours > 12) { Hours -= 12; } if (Hours == 0) { Hours = 12; } Mins = Stamp.getMinutes(); if (Mins < 10) { Mins = "0" + Mins; } document.getElementById('timer').innerHTML = '<B>Todays Time:</b> ' + Hours + ":" + Mins + Time + ''; } </SCRIPT> <body onload="setInterval('TheDay();', 1000);"> <div id="timer"> </div> </body> Quote Link to comment https://forums.phpfreaks.com/topic/67015-local-time-script-issue/#findComment-336067 Share on other sites More sharing options...
live_ex3me Posted August 28, 2007 Author Share Posted August 28, 2007 Use AJAX, Frames, javascript.. nothing thats PHP based really.. i know javascript, ajax, but not so well.. i'll try what u gave me, thanks ! i'll be back to tell wether it worked or not LE: well.. it seems not to work.. but anyway, i know you can show the time live in javascript, but i need to do this for various zones on earth, for tokyo, london, new york, etc.. i need to show what the time is in these locations in the same script.. php would do that, but not in real time. ??? Quote Link to comment https://forums.phpfreaks.com/topic/67015-local-time-script-issue/#findComment-336070 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.