Time Zones Are Hard - https://tz.rita.moe

Improvements for no-js/textual browsers

Changed files
+13 -5
+13 -5
index.php
···
echo ' ' . toTZ($dt, $_COOKIE['user-tz'], 'l \t\h\e jS \o\f F, Y \a\t ' . $hm) . PHP_EOL;
} else if ($_COOKIE['has-js'] !== '1') {
?>
-
Sorry, we use JavaScript to detect your local time.<br/>
-
Enable it or select your time zone:<br/>
<form method="post">
<select required id="user-tz" name="user-tz">
<option selected disabled>(pick one)</option>
···
<?php } ?>
</optgroup>
</select>
-
<button type="submit">Submit</button><br/>
<input type="checkbox" id="user-24" name="user-24"/>
<label for="user-24"><span>24h format</span></label>
</form>
<?php } else { ?>
Did you turn off Javascript?<br/>
···
</div>
<div class="share">
-
<button type="button" onclick="shareURL()">Share</button>
<input type="hidden" id="url" value="https://tz.kdy.ch<?= $_SERVER['REQUEST_URI'] ?>"/>
</div>
···
document.querySelector('.local').innerHTML = localDT + '<br/><span>(' + relative + ')</span>'
// Display share button
-
document.querySelector('.share').style.display = 'block'
// Our share URL function
function shareURL () {
···
</p>
<form action="/" method="post">
<label for="datetime">Date and Time:</label>
<input required type="datetime-local" id="datetime" name="datetime"/>
···
echo ' ' . toTZ($dt, $_COOKIE['user-tz'], 'l \t\h\e jS \o\f F, Y \a\t ' . $hm) . PHP_EOL;
} else if ($_COOKIE['has-js'] !== '1') {
?>
+
Please select your local time zone <small>(or enable JavaScript)</small>:<br/>
<form method="post">
<select required id="user-tz" name="user-tz">
<option selected disabled>(pick one)</option>
···
<?php } ?>
</optgroup>
</select>
+
<br/>
<input type="checkbox" id="user-24" name="user-24"/>
<label for="user-24"><span>24h format</span></label>
+
<br/>
+
<button type="submit">Submit</button>
</form>
<?php } else { ?>
Did you turn off Javascript?<br/>
···
</div>
<div class="share">
<input type="hidden" id="url" value="https://tz.kdy.ch<?= $_SERVER['REQUEST_URI'] ?>"/>
</div>
···
document.querySelector('.local').innerHTML = localDT + '<br/><span>(' + relative + ')</span>'
// Display share button
+
const shareButton = document.createElement('button')
+
shareButton.type = 'button'
+
shareButton.textContent = 'Share'
+
shareButton.onclick = shareURL
+
document.querySelector('.share').appendChild(shareButton)
// Our share URL function
function shareURL () {
···
</p>
<form action="/" method="post">
+
<noscript>
+
<small>(If you only see a plain input, use the "YYYY-MM-DD HH:MM" format.)</small>
+
<br/>
+
</noscript>
<label for="datetime">Date and Time:</label>
<input required type="datetime-local" id="datetime" name="datetime"/>