From a53376f57e42e8e173709d838f6de5bfe8c2607e Mon Sep 17 00:00:00 2001 From: efrick Date: Tue, 31 Mar 2020 22:15:41 -0400 Subject: [PATCH] Cleaned up both the PHP/HTML and JavaScript code. Removed the orignal PHP date formating. The code now runs so that PHP will inishilize a view on the page and JS will then update this. The formating of the Timezone doesn't seem to be consistant acrossed browsers. And JS doesn't format time with leading zeros for minutes or seconds which is odd. This may be fixed in a further revision. --- clock.js | 5 ++--- clock.php | 23 ++++++++++------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/clock.js b/clock.js index 5d7516d..0613d78 100644 --- a/clock.js +++ b/clock.js @@ -5,11 +5,10 @@ function startInterval(){ } function startTime(){ - var current_time = new Date(); - var formated_time = current_time.getHours() + ":" + var current_time = new Date(), + formated_time = current_time.getHours() + ":" + current_time.getMinutes() + ":" + current_time.getSeconds(); document.getElementById('time_title').innerHTML = "Time is: " + formated_time; document.getElementById('time_body').innerHTML = Date(); - document.getElementById('time_test').innerHTML = current_time.getDate(); } diff --git a/clock.php b/clock.php index 4de8867..3613970 100644 --- a/clock.php +++ b/clock.php @@ -1,6 +1,10 @@ - Clock + + <?php + echo "Time is: " . date("H:i:s"); + ?> + @@ -13,19 +17,12 @@
"; - echo "

Clock

"; - $my_tz = date_timezone_get(); - echo date("l M d Y H:i:s") . "$my_tz"; - function longdate($timestamp) - { - return date("l F jS Y", $timestamp); - } - + echo "The full date and time:". + "
". + "

". + date("D M d Y H:i:s") . + " GMT" . date("O") . " (" . date("T") . ")"."

"; ?> -

Test