Time Zone Conversion

Javascript snippets to help with time zone conversion.

const UTC = d => new Date(d).toJSON() const zone = z => { const dtf = Intl.DateTimeFormat("en-CA", { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", hour12: false, minute: "2-digit", timeZone: z, timeZoneName: "short" }) return d => dtf.format(d) } const JST = zone("Asia/Tokyo") const PST = zone("America/Los_Angeles") const MST = zone("America/Denver") const CST = zone("America/Chicago") const EST = zone("America/New_York")

Intl.DateTimeFormat mdn

import * as frame from "https://wiki.dbbs.co/assets/v1/frame.js" export async function emit(el) { const now = new Date() el.innerHTML = [JST, UTC, PST, MST, CST, EST] .map(convert => `<p>${convert(now)}</p>`) .join("\n") frame.resize() }

In the frame below we can view the results.

//wiki.dbbs.co/assets/pages/js-snippet-template/esm.html HEIGHT 400