Advertisement
Shailrshah

AJAX date

Apr 23rd, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <script>
  5.         function getTime(){
  6.             setTimeout("getTime()", 1000);
  7.             var xmlhttp = new XMLHttpRequest();
  8.             xmlhttp.onreadystatechange = function() {
  9.                 document.getElementById("c").innerHTML=xmlhttp.responseText;
  10.             }
  11.             xmlhttp.open("GET", "time.php",true);
  12.             xmlhttp.send();
  13.             document.getElementById('d').innerHTML=Date();
  14.         }
  15.         getTime();     
  16.        
  17.     </script>
  18. </head>
  19. <body>
  20.     <p>PHP says <span id="c"> </span></p>
  21.     <p>JavaScript says the time is <span id="d"></span><p>
  22. </body>
  23. </html>
  24.  
  25.  
  26. <?php
  27.     echo "The date and time is " . date("d/mY h:i:sa") . ".";
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement