how to display system time in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
myasirm
Forum Commoner
Posts: 54
Joined: Sat Sep 12, 2009 3:57 am

how to display system time in php

Post 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 .
DacehallReggae
Forum Newbie
Posts: 1
Joined: Tue Nov 10, 2009 2:06 am

Re: how to display system time in php

Post by DacehallReggae »

hello all have a nice day
myasirm
Forum Commoner
Posts: 54
Joined: Sat Sep 12, 2009 3:57 am

Re: how to display system time in php

Post by myasirm »

i have asked a question man if u know kindly tell me
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: how to display system time in php

Post by pbs »

Use like this

Code: Select all

 
<?php
echo date("F j, Y, g:i a");                 
?>
 
myasirm
Forum Commoner
Posts: 54
Joined: Sat Sep 12, 2009 3:57 am

Re: how to display system time in php

Post 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
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: how to display system time in php

Post by pbs »

Then you will need to do it in javascript
myasirm
Forum Commoner
Posts: 54
Joined: Sat Sep 12, 2009 3:57 am

Re: how to display system time in php

Post by myasirm »

so kindly send me the code in java script for that i have no more idea about that

waiting for reply
User avatar
N1gel
Forum Commoner
Posts: 95
Joined: Sun Apr 30, 2006 12:01 pm

Re: how to display system time in php

Post 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);
 
myasirm
Forum Commoner
Posts: 54
Joined: Sat Sep 12, 2009 3:57 am

Re: how to display system time in php

Post by myasirm »

but i don't want to reload whole page after each second i want to refresh only time after each second
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: how to display system time in php

Post 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>
 
 
 
myasirm
Forum Commoner
Posts: 54
Joined: Sat Sep 12, 2009 3:57 am

Re: how to display system time in php

Post 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
myasirm
Forum Commoner
Posts: 54
Joined: Sat Sep 12, 2009 3:57 am

Re: how to display system time in php

Post by myasirm »

Thanks to all of u guys i resolved my problem thx
Post Reply