[2025-04-14] Handle timezone correctly with zoneinfo

This commit is contained in:
Andrew Conlin 2025-04-14 18:20:48 +09:00
parent 5489c69d04
commit 7a9a9a5eb2
2 changed files with 15 additions and 8 deletions

View file

@ -2,6 +2,7 @@
<div style="visibility: hidden">
<form id="form" method="POST" action="/">
<input name="timestamp" id="timestamp" type="number"></input>
<input name="timezone" id="timezone" type="text"></input>
</form>
</div>
</html>
@ -9,10 +10,14 @@
window.onload = function(e){
var d = new Date();
var timestamp = Math.round(d.getTime() / 1000);
input = document.getElementById("timestamp")
input.value = timestamp;
var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
ts = document.getElementById("timestamp")
ts.value = timestamp;
tz = document.getElementById("timezone")
tz.value = timezone;
form = document.getElementById("form")
form.submit();
console.log(timestamp);
console.log(timezone);
}
</script>