Page 1 of 1
how to display system time in php
Posted: Tue Nov 10, 2009 2:02 am
by myasirm
hi guys i want to display system time which is running time on system i mean to say when time is change in system clock it will automatically change on my page no need to to refresh the page
so kindly help me in this regards if any one know
thanks in advance waiting for ur replies .
Re: how to display system time in php
Posted: Tue Nov 10, 2009 2:09 am
by DacehallReggae
hello all have a nice day
Re: how to display system time in php
Posted: Tue Nov 10, 2009 2:14 am
by myasirm
i have asked a question man if u know kindly tell me
Re: how to display system time in php
Posted: Tue Nov 10, 2009 2:30 am
by pbs
Use like this
Code: Select all
<?php
echo date("F j, Y, g:i a");
?>
Re: how to display system time in php
Posted: Tue Nov 10, 2009 2:37 am
by myasirm
thanks for ur reply i have used this code but it show current time by refreshing the page if i am at one page for half hour than this time is not the system time so i want to the code which automatically refresh the time with out refreshing whole page
waiting for ur replies
Re: how to display system time in php
Posted: Tue Nov 10, 2009 2:40 am
by pbs
Then you will need to do it in javascript
Re: how to display system time in php
Posted: Tue Nov 10, 2009 2:42 am
by myasirm
so kindly send me the code in java script for that i have no more idea about that
waiting for reply
Re: how to display system time in php
Posted: Tue Nov 10, 2009 2:44 am
by N1gel
You will need to use a Javascript Timeout
This bit of Javascript will reload your page every second
Code: Select all
window.setTimeout(function()
{
window.location.reload();
}, 1000);
Re: how to display system time in php
Posted: Tue Nov 10, 2009 2:48 am
by myasirm
but i don't want to reload whole page after each second i want to refresh only time after each second
Re: how to display system time in php
Posted: Tue Nov 10, 2009 2:56 am
by pbs
Try this
Code: Select all
<html>
<head>
<title>Timer</title>
<script language="javascript">
function setTimer()
{
var d = new Date();
var t_hour = d.getHours(); // Returns hours
var t_min = d.getMinutes(); // Returns minutes
var t_sec = d.getSeconds(); // Returns seocnds
var curtime = t_hour +":"+ t_min +":"+ t_sec;
var obj = document.getElementById('timer');
obj.innerHTML = curtime;
}
setInterval('setTimer()',1000);
</script>
</head>
<body>
<div id="timer" style="font:Verdana, Arial, Helvetica, sans-serif; font-weight:bolder;"></div>
</body>
</html>
Re: how to display system time in php
Posted: Tue Nov 10, 2009 5:54 am
by myasirm
thanks dear for ur cooperation exactly same thing i need now just kindly tell me i want to display date and time in this format so what changes i need
Wednesday, November 11, 2009 3:58:49 AM
waiting for ur reply
Re: how to display system time in php
Posted: Tue Nov 10, 2009 6:29 am
by myasirm
Thanks to all of u guys i resolved my problem thx