TCH-Thomas Posted April 29, 2004 Posted April 29, 2004 A few days ago someone here got me interested in php, so i thought i would try some more and i found this script ><?php $newdate = date("Y-m-d H:i:s", strtotime("6 HOUR")); echo $newdate; ?> Which shows the current time and date. The problem is that the time is static. The time is still the same, even 10 minutes after the visitor arrived to the site unless the visitor refresh the page itself (or frame in my case). Can this code be changed to refresh itself, doesnt have to be every second but each minute would be nice. Or should i change script completely? Quote
TCH-Bruce Posted April 29, 2004 Posted April 29, 2004 I don't think so. PHP is processed by the server as the page is being sent to the user's browser so since there is no refresh of the page the clock will remain static. You will have to use a META refresh tag on the page to have it reload or use something in javascript or the clock in cPanel. Quote
Deverill Posted April 29, 2004 Posted April 29, 2004 Check hotscripts.com for a javascript snippet. Javascript runs on the visitor's pc so it can do up-to-the-second updates. As Bruce said, PHP is interpreted by the server so you don't have the same flexibility. Quote
TCH-Thomas Posted April 30, 2004 Author Posted April 30, 2004 I found this code a while ago. At that time i used it on a english speaking site so i didnt have to change anything but now i wanna use it on a swedish site and we use 24h time. ><HEAD> <script LANGUAGE="javascript"> <!-- Original: Craig Lumley --> <!-- Web Site: http://www.ws4all.co.uk --> <!-- This script and many more are available free online at --> <!-- The javascript Source!! http://javascript.internet.com --> <!-- Begin function MakeArrayday(size) { this.length = size; for(var i = 1; i <= size; i++) { this[i] = ""; } return this; } function MakeArraymonth(size) { this.length = size; for(var i = 1; i <= size; i++) { this[i] = ""; } return this; } function funClock() { if (!document.layers && !document.all) return; var runTime = new Date(); var hours = runTime.getHours(); var minutes = runTime.getMinutes(); var seconds = runTime.getSeconds(); var dn = "AM"; if (hours >= 12) { dn = "PM"; hours = hours - 12; } if (hours == 0) { hours = 12; } if (minutes <= 9) { minutes = "0" + minutes; } if (seconds <= 9) { seconds = "0" + seconds; } movingtime = ""+ hours + ":" + minutes + ":" + seconds + " " + dn + ""; if (document.layers) { document.layers.clock.document.write(movingtime); document.layers.clock.document.close(); } else if (document.all) { clock.innerHTML = movingtime; } setTimeout("funClock()", 1000) } window.onload = funClock; // End --> </script> </HEAD> ><BODY> <span id=clock style="position:relative;"></span> Is there any way I can get rid of AM/PM and make it show 13, 14, 15 and so on instead of 1, 2, 3...? Quote
arvind Posted April 30, 2004 Posted April 30, 2004 That would show the visitor's current date & time is there some way to display the servers data & time through java. And in that process show my date & time by adding a number to the server's ! Quote
TCH-Thomas Posted April 30, 2004 Author Posted April 30, 2004 I got confused over your answer Arvind. Sorry. But, please disregard my last post, cause i found a script that does exactly what i want. If you wanna look, take a look at the top in LEFT frame at this page. Quote
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.