Jump to content

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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