# Systems >> Localize >> Format Dates ||40 ## Features - Small file size - Uses `Intl.DateFormat` but patches browser inconsistencies ## Formatting With the `formatDate` you can safely display dates for all languages. The input value is `new Date('1987/05/12')`. ```js script import { css, html } from '@mdjs/mdjs-preview'; import { formatNumber, formatNumberToParts, formatDate } from '@lion/localize'; import allLocales from './assets/all-locales.js'; const formatDateDemoStyle = css` .demo-table { border-collapse: collapse; text-align: right; } .demo-table thead > tr { border-bottom: 1px solid grey; } .demo-table thead > tr > :first-child, .demo-table tbody > tr > :first-child, .demo-table tfoot > tr > :first-child { text-align: left; } .demo-table th, .demo-table td { padding: 8px; } `; ``` ```js preview-story export const formatting = () => html`
Output Options Code
${formatDate(new Date('1987/05/12'))} Default formatDate(new Date('1987/05/12'))
${formatDate(new Date('1987/05/12'), { weekday: 'long', year: 'numeric', month: 'long', day: '2-digit', })} Date display formatDate(new Date(){weekday:'long',year:'numeric',month:'long',day:'2-digit'})
${formatDate(new Date('1987/05/12'), { weekday: 'long', month: 'long', day: '2-digit', })} Date without year formatDate(new Date('1987/05/12'), {weekday:'long',month:'long',day:'2-digit'})
${formatDate(new Date('1987/05/12'), { weekday: 'long', year: 'numeric', day: '2-digit', })} Date without month formatDate(new Date('1987/05/12'), {weekday:'long',year:'numeric',day:'2-digit'})
${formatDate(new Date('1987/05/12'), { weekday: 'long', month: 'long', year: 'numeric', })} Date without day formatDate(new Date('1987/05/12'), { weekday:'long',year:'numeric',month:'long' })
${formatDate(new Date('1987/05/12'), { locale: 'nl-NL' })} Locale formatDate(new Date('1987/05/12'){ locale:'nl-NL' })
`; ``` ## List common locales The input value is `new Date('1987/05/12')`. Formatting happens via ```js formatDate(new Date('1987/05/12'), { locale }); ``` ```js preview-story export const listCommonLocales = () => html` ${['en-GB', 'en-US', 'nl-NL', 'nl-BE', 'fr-FR', 'de-DE'].map( locale => html` `, )}
Locale Output
${locale} ${formatDate(new Date('1987/05/12'), { locale })}
`; ``` ## List all locales The following list shows date formatting for all known locales. The input value is `new Date('1987/05/12')`. Formatting happens via ```js formatDate(new Date('1987/05/12'), { locale }); ``` ```js preview-story export const listAllLocales = () => html` ${Object.keys(allLocales).map( locale => html` `, )}
Locale Output
${locale} ${formatDate(new Date('1987/05/12'), { locale })}
`; ```