lion/packages/localize/docs/date.md
Thomas Allmer ec8da8f12c feat: release inital public lion version
Co-authored-by: Mikhail Bashkirov <mikhail.bashkirov@ing.com>
Co-authored-by: Thijs Louisse <thijs.louisse@ing.com>
Co-authored-by: Joren Broekema <joren.broekema@ing.com>
Co-authored-by: Gerjan van Geest <gerjan.van.geest@ing.com>
Co-authored-by: Erik Kroes <erik.kroes@ing.com>
Co-authored-by: Lars den Bakker <lars.den.bakker@ing.com>
2019-04-26 10:37:57 +02:00

803 B

Date

The date formatter returns a date based on the locale by using Intl DateTimeFormat specification.

Features

  • formatDate: returns a formatted date based on locale
  • parseDate: returns a date Object
  • getDateFormatBasedOnLocale: returns the date format based on locale

How to use

Installation

npm i --save @lion/localize;

Example

import { parseDate, formatDate } from '@lion/localize';

function dateExampleFunction () {
  const parsedDate = parseDate('21-05-2012');
  const options = {
    weekday: 'long', year: 'numeric', month: 'long', day: '2-digit',
  };

  return formatDate(parsedDate, options) // 'Monday, 21 May 2012' for British locale
}