Skip to content
Snippets Groups Projects
formatDate.ts 319 B
/**
 * Util to format a date complying to server format.
 * @param date date to format.
 * @returns date formatted in format YYYY-MM-DD.
 */
export const formatDate = (date: Date): string =>
  date !== null && date !== undefined
    ? `${date.getUTCFullYear()}-${date.getUTCMonth() + 1}-${date.getUTCDate()}`
    : '';