From: David Polakovic Date: Sun, 30 Mar 2025 09:48:21 +0000 (+0200) Subject: modified for summer/winter time shifts X-Git-Url: https://git.dpolakovic.space/?a=commitdiff_plain;h=d2cb62abecab6ea52f10064fa8f995948cf09138;p=my-website modified for summer/winter time shifts --- diff --git a/mars-clock.php b/mars-clock.php index 7e3aa43..7f1d7c1 100755 --- a/mars-clock.php +++ b/mars-clock.php @@ -53,10 +53,10 @@ ------------------------------------------------------ Earth | Time | Date | ------------------------------------------------------ -Silicon Valley | | | -Boston | | | -London* | | | -Tokyo | | | +Silicon Valley | | | +Boston | | | +London* | | | +Tokyo | | | ------------------------------------------------------ Mars | Time | Date | diff --git a/php/time.php b/php/time.php old mode 100755 new mode 100644 index dfcc234..8a6905b --- a/php/time.php +++ b/php/time.php @@ -8,29 +8,22 @@ function title() { //echo "Data valid to time: ". $current_time . "
"; } - function timeEarth($offset) { - - $dateTime = new DateTime("now", new DateTimeZone("UTC")); - - // Modify the timezone using the provided offset - $timezoneName = sprintf("Etc/GMT%+d", -$offset); - $dateTime->setTimezone(new DateTimeZone($timezoneName)); - - // Print the formatted time - echo $dateTime->format("H:i"); - +function timeEarth($timezone) { + try { + $dateTime = new DateTime("now", new DateTimeZone($timezone)); + echo $dateTime->format("H:i"); + } catch (Exception $e) { + echo "Invalid timezone provided."; + } } - function dateEarth(int $offset) { - // Create a DateTime object for the current date - $dateTime = new DateTime("now", new DateTimeZone("UTC")); - - // Modify the timezone using the provided offset - $timezoneName = sprintf("Etc/GMT%+d", -$offset); - $dateTime->setTimezone(new DateTimeZone($timezoneName)); - - // Print the formatted date - echo $dateTime->format("d-m(M)-Y"); +function dateEarth($timezone) { + try { + $dateTime = new DateTime("now", new DateTimeZone($timezone)); + echo $dateTime->format("d-m(M)-Y"); + } catch (Exception $e) { + echo "Invalid timezone provided"; + } } function get_time_m(){