From 1ff7d4080ce0aa22d683400d54610a531c1625cf Mon Sep 17 00:00:00 2001 From: efrick Date: Wed, 15 Apr 2020 21:06:36 -0400 Subject: [PATCH] Fix the check for a non value in the time update for original timezone. --- clock.css | 3 +++ clock.js | 4 ++-- clock.php | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/clock.css b/clock.css index 18d440c..0d85a54 100644 --- a/clock.css +++ b/clock.css @@ -4,3 +4,6 @@ span p{ select { max-width: 95%; } +.chkbox { + display: inline-block; +} diff --git a/clock.js b/clock.js index 2b6c2c5..98cc7eb 100644 --- a/clock.js +++ b/clock.js @@ -34,7 +34,7 @@ function startTime(){ hour:'2-digit', minute:'2-digit', second:'2-digit',}); - if(original_tz != null){ + if(original_tz){//Test if there is a non-null value for original_tz. If True then the part of the page this pertains to is being displayed. document.getElementById('time_original').innerHTML = current_time.toLocaleString('en-EN' ,{ timeZone: original_tz, dateStyle:'long', @@ -47,5 +47,5 @@ function startTime(){ minute:'2-digit', second:'2-digit'}); } - document.getElementById('JStz').innerHTML = current_tz; + //document.getElementById('JStz').innerHTML = current_tz; } diff --git a/clock.php b/clock.php index 1bd394b..4ef3c76 100644 --- a/clock.php +++ b/clock.php @@ -9,8 +9,10 @@ if(!isset($selectedTimezone)){ //I don't have any error message set here. It will just reload the page. } else{ + $origHour = date('O'); $originalTZ = date_default_timezone_get(); date_default_timezone_set($selectedTimezone); + $scriptHour = date('O'); $scriptTZ = date_default_timezone_get(); } } else{ @@ -52,6 +54,10 @@ "

GMT". date("O T") .'

'; date_default_timezone_set($scriptTZ); } + if($_POST['displayOffset']){ + $tzDifferance = (-1 * ($origHour - $scriptHour)) * 0.01; + echo '

The difference between the timezones is ' . $tzDifferance . ' hours

'; + } ?>

@@ -103,6 +109,10 @@
+ Display offset of selected timezones + +