Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

353 B
Raw Blame
export function shortDateTime(
  date: string | number | Date,
  includeTime: boolean = true
) {
  return new Date(date).toLocaleString("en-US", {
    year: "numeric",
    month: "short",
    day: "numeric",
    ...(includeTime
      ? {
          hour: "numeric",
          minute: "numeric",
          second: "numeric",
        }
      : {}),
  })
}