-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathepoch-converter.html
More file actions
40 lines (36 loc) · 1.25 KB
/
epoch-converter.html
File metadata and controls
40 lines (36 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="/logo.svg">
<title>Echo Converter</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script type="module">
import van from "./van-latest.min.js"
const {b, button, div, i, input, p} = van.tags
const tsToDate = ts =>
ts < 1e10 ? new Date(ts * 1e3) :
ts < 1e13 ? new Date(ts) :
ts < 1e16 ? new Date(ts / 1e3) :
new Date(ts / 1e6)
const Converter = () => {
const nowTs = van.state(Math.floor(new Date().getTime() / 1e3)), date = van.state(null)
setInterval(() => ++nowTs.val, 1000)
const inputDom = input({type: "text", size: 25, value: nowTs.val})
return div(
div(b("Now: "), nowTs),
inputDom, " ",
button({onclick: () => date.val = tsToDate(Number(inputDom.value))}, "Convert"),
p(i("Supports Unix timestamps in seconds, milliseconds, microseconds and nanoseconds.")),
() => date.val ? p(
div(date.val.toString()),
div(b("GMT: "), date.val.toGMTString()),
) : p(),
)
}
van.add(document.body, Converter())
</script>
</body>
</html>