Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Current time code
#4
Here you go

time.php
PHP Code:
<?php
print date("H:i:s");
?>

HTML file
javascript from : http://www.w3schools.com/Ajax/ajax_xmlhttprequest.asp
Code:
<html>
<head>

<script type="text/javascript">
function ajaxFunction()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
  document.getElementById("clock").innerHTML=xmlhttp.responseText;
  }
}
xmlhttp.open("GET","time.php",true);
xmlhttp.send(null);
}
</script>

</head>
<body onload="setInterval('ajaxFunction()', 1000);">

<div id="clock"></div>

</body>
</html>

If you want to output only Hours:Minutes just remove "Confused" from the date() function

PHP Code:
<?php
print date("H:i");
?>
Reply


Messages In This Thread
Current time code - by rockclimber66 - 10-09-2009, 02:55 PM
RE: Current time code - by Elektrisk - 10-09-2009, 03:05 PM
RE: Current time code - by Alex - 10-09-2009, 07:20 PM
RE: Current time code - by Gaijin - 10-09-2009, 07:23 PM
RE: Current time code - by rockclimber66 - 10-10-2009, 02:02 AM
RE: Current time code - by Gaijin - 10-10-2009, 09:19 AM
RE: Current time code - by Legion - 10-10-2009, 10:13 AM
RE: Current time code - by Alex - 10-10-2009, 06:52 PM
RE: Current time code - by Code King - 10-10-2009, 09:26 AM
RE: Current time code - by Gaijin - 10-10-2009, 09:28 AM
RE: Current time code - by HuNt3R - 10-11-2009, 09:28 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)