Jump to content

Local Time Script Issue


live_ex3me

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/67015-local-time-script-issue/
Share on other sites

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>

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.  ???

 

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.