···
if (isset($_POST['user-24'])) {
36
-
setcookie('user-24', '1', time() + 60 * 60 * 24);
36
+
setcookie('user-24', '1', time() + 60 * 60 * 24 * 365);
$_COOKIE['user-24'] = '1';
40
+
// If had JS enabled but doesn't now, remove cookie
41
+
if (isset($_POST['no-js'])) {
42
+
setcookie('has-js', '0', time() + 60 * 60 * 24 * 365);
43
+
$_COOKIE['has-js'] = '0';
···
if (isset($_COOKIE['user-tz'])) {
$hm = $_COOKIE['user-24'] === '1' ? 'H:i' : 'h:i a';
119
-
echo toTZ($dt, $_COOKIE['user-tz'], 'l \t\h\e jS \o\f F, Y \a\t ' . $hm);
125
+
// I put spaces just so it looks nice in the source code
126
+
echo ' ' . toTZ($dt, $_COOKIE['user-tz'], 'l \t\h\e jS \o\f F, Y \a\t ' . $hm) . PHP_EOL;
127
+
} else if($_COOKIE['has-js'] !== '1') {
Sorry, we use JavaScript to detect your local time.<br/>
Enable it or select your time zone:<br/>
···
<input type="checkbox" id="user-24" name="user-24"/>
<label for="user-24"><span>24h format</span></label>
154
+
Did you turn off Javascript?<br/>
155
+
<form method="post">
156
+
<input type="hidden" name="no-js" value="1"/>
157
+
<button type="submit">Reload to no-JS</button>
···
<?php foreach($popTZ as $tz) { ?>
<div class="tz-table-element">
159
-
<?= $tz === 'UTC' ? 'UTC' : str_replace('_', ' ', explode('/', $tz, 2)[1]) . ' (' . getOffset($tz) . ')' ?>
169
+
<strong><?= $tz === 'UTC' ? 'UTC' : str_replace('_', ' ', explode('/', $tz, 2)[1]) . ' (' . getOffset($tz) . ')' ?></strong>
<span><?= toTZ($dt, $tz) ?></span>
···
© <?= date('Y') ?> Kody - Made with 🍮<br/>
<a href="https://thenounproject.com/icon/wall-clock-5456766/" target="_blank" title="Wall Clock Icon" rel="noopener">Wall Clock by Basicon</a> from Noun Project (CC BY 3.0)
294
+
// Save on the request size if user has JavaScript
295
+
const date = new Date()
296
+
date.setTime(date.getTime() + (1000 * 60 * 60 * 24 * 365))
297
+
document.cookie = 'has-js=1; expires=' + date.toUTCString() + '; path=/'