Back to Fullcalendar

formatDate

_docs-v5/date-library/formatDate.md

latest843 B
Original Source

A utility function that formats a date into a string.

<div class='spec' markdown='1'> FullCalendar.formatDate( *date*, *settings* ) </div>

date can be a Date Object or something that will parse into a Date Object.

settings is an object that holds any of the date format config options. It also accepts the following additional properties:

  • locale — the name of a locale like 'es'
  • timeZone — the name of a time zone. Either 'local', 'UTC', or a named time zone

Example:

js
import { formatDate } from '@fullcalendar/core'

let str = formatDate('2018-09-01', {
  month: 'long',
  year: 'numeric',
  day: 'numeric',
  timeZoneName: 'short',
  timeZone: 'UTC',
  locale: 'es'
})

console.log(str) // "1 de septiembre de 2018 0:00 UTC"