35 lines
1002 B
TypeScript
35 lines
1002 B
TypeScript
export function displayTimestamp(unixTimestamp: number): string {
|
|
const expireDate = new Date(unixTimestamp);
|
|
const dateString = new Intl.DateTimeFormat("en-US", {
|
|
year: "numeric",
|
|
month: "long",
|
|
day: "numeric",
|
|
}).format(expireDate);
|
|
const timeString = new Intl.DateTimeFormat("en-US", {
|
|
hour: "numeric",
|
|
minute: "numeric",
|
|
second: "numeric",
|
|
hour12: false,
|
|
timeZoneName: "long",
|
|
}).format(expireDate);
|
|
return `${dateString} at ${timeString}`;
|
|
}
|
|
|
|
export function displayTimestampUtc(unixTimestamp: number): string {
|
|
const expireDate = new Date(unixTimestamp);
|
|
const dateString = new Intl.DateTimeFormat("en-US", {
|
|
year: "numeric",
|
|
month: "long",
|
|
day: "numeric",
|
|
timeZone: "UTC",
|
|
}).format(expireDate);
|
|
const timeString = new Intl.DateTimeFormat("en-US", {
|
|
hour: "numeric",
|
|
minute: "numeric",
|
|
second: "numeric",
|
|
hour12: false,
|
|
timeZone: "UTC",
|
|
}).format(expireDate);
|
|
return `${dateString} at ${timeString}`;
|
|
}
|