MCPcopy Index your code
hub / github.com/simstudioai/sim / formatDateTime

Function formatDateTime

packages/utils/src/formatting.ts:60–77  ·  view source on GitHub ↗
(date: Date, timezone?: string)

Source from the content-addressed store, hash-verified

58 * @returns A formatted date string in the format "MMM D, YYYY h:mm A"
59 */
60export function formatDateTime(date: Date, timezone?: string): string {
61 const formattedDate = date.toLocaleString('en-US', {
62 month: 'short',
63 day: 'numeric',
64 year: 'numeric',
65 hour: 'numeric',
66 minute: '2-digit',
67 hour12: true,
68 timeZone: timezone || undefined,
69 })
70
71 if (timezone) {
72 const tzAbbr = getTimezoneAbbreviation(timezone, date)
73 return `${formattedDate} ${tzAbbr}`
74 }
75
76 return formattedDate
77}
78
79/**
80 * Format a date into a short format

Callers 6

getScheduleInfoFunction · 0.90
utils.test.tsFile · 0.90
ForkJobRowFunction · 0.90
VersionsFunction · 0.90
AuditLogRowFunction · 0.90
formatting.test.tsFile · 0.85

Calls 1

getTimezoneAbbreviationFunction · 0.70

Tested by

no test coverage detected