Andu Jame Posted May 9, 2007 Share Posted May 9, 2007 ??? What are the code to make "time" in website, automatically follows the server time the code i hv tried is: <? $today=date("F j,Y, g:i a"); echo date ("F j,Y, g:i a"); ?> this code make appear the time at my page but i'hv to refresh the page each time i open it..!! Quote Link to comment https://forums.phpfreaks.com/topic/50616-code-pls/ Share on other sites More sharing options...
mmarif4u Posted May 9, 2007 Share Posted May 9, 2007 Php is server side so u cannot use it without refresh, Use js for real time. Quote Link to comment https://forums.phpfreaks.com/topic/50616-code-pls/#findComment-248782 Share on other sites More sharing options...
Andu Jame Posted May 9, 2007 Author Share Posted May 9, 2007 can u pleasegive that j.script??? i'm really very urgent to finish my page...bcoz i'm quit delay with my project.. Quote Link to comment https://forums.phpfreaks.com/topic/50616-code-pls/#findComment-248788 Share on other sites More sharing options...
mmarif4u Posted May 9, 2007 Share Posted May 9, 2007 <body> <SCRIPT> document.write(Date()+".") </SCRIPT> </body> Remember put in the body, not in the head. Quote Link to comment https://forums.phpfreaks.com/topic/50616-code-pls/#findComment-248794 Share on other sites More sharing options...
Andu Jame Posted May 9, 2007 Author Share Posted May 9, 2007 Thanks a lot Actually i am doing punch card system for two department, they are using bar code scanner. Now,i have got problem with php code to controlling that two department to punch at same time but using only one server and two computers.It means, officer in department A can not punch card at department B and it same goes to officer in department B. What should i do,Can u pls HELP me with that php or js code Well..im really new to this programming. Quote Link to comment https://forums.phpfreaks.com/topic/50616-code-pls/#findComment-248809 Share on other sites More sharing options...
mmarif4u Posted May 9, 2007 Share Posted May 9, 2007 I did not get ur question completely but for u to explain... Php is server side if u want to display date or time then u reload the page for that to get live time. Javascript give live time running with seconds, so it is the most proper way to do it. As my suggestion use js script for this type of situation. If not clear can post for more explanation. Try this code for real 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 = "<b>"+ hours + ":" + minutes + ":" + seconds + " " + dn + "</b>"; 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> Currently, it's <span id=clock style="position:relative;"></span> <p><center> <font face="arial, helvetica" size="-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </center><p> Quote Link to comment https://forums.phpfreaks.com/topic/50616-code-pls/#findComment-248813 Share on other sites More sharing options...
Andu Jame Posted May 9, 2007 Author Share Posted May 9, 2007 The time is working, I have another problem. Actually im trying control two system working separately, that system using for punch card their attendance. What are the code i should use?? To make that system works separate by using one server. Should i control it by IP address?? Quote Link to comment https://forums.phpfreaks.com/topic/50616-code-pls/#findComment-248816 Share on other sites More sharing options...
mmarif4u Posted May 9, 2007 Share Posted May 9, 2007 I am not sure about these things , but one thing in my mind is that the js code is client side, If there is one min diff in the remote computer then it is easly controlled by one server. I mean that the time in js is if u put on the client computer then ok if on server then i am not sure to do bcoz i did not go for these things before, other u can try the IP address to catch the time. Quote Link to comment https://forums.phpfreaks.com/topic/50616-code-pls/#findComment-248819 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.