1
2
3
4
5
6
7
8
9
10
11
// Outputs, e.g., "It is currently Sunday, May 21, 2023 at 12:11:04 PM Pacific Daylight Time."
// timeZone should be a tz identifier as listed at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
export function formatCurrentDatetimeSentence(timeZone: string): string {
const dateFormatter = new Intl.DateTimeFormat([], {
dateStyle: "full",
timeStyle: "full",
timeZone,
});
const now = dateFormatter.format(Date.now());
return `It is currently ${now}.`;
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.