Skip to content

FormatDate

Used to format dates to a specific format.

1.01.2021, 1:01 PM
1 Jan 2021
January, 1st of 2021
2021-01-01 13:01:00
import { FormatDate } from '@fintech-sandpit/ui/react';
const value = new Date('2021-01-01 13:00:00');
return (
<FormatDate value={value} />
<FormatDate
value={value}
format="%j %M %Y"
/>
<FormatDate
value={value}
format="%F, %j%S of %Y"
/>
<FormatDate
value={value}
format="%Y-%m-%d %H:%m:%s"
/>
);
NameTypeRequiredDefaultDescription
valueDate | stringYesValue to format
formatstring%j.%m.%Y, %g:%m %ADate and time format to use 1
  1. See the the table below for the available formats.
FormatDescriptionExample
%YYear (4-digit)2021
%yYear (2-digit)21
%mMonth number (with leading zero: 01-12)01
%nMonth number (without leading zero: 1-12)1
%MMonth name (short form: Jan)Jan
%FMonth name (full form: January)January
%dDay (01-31)01
%jDay (1-31)1
%SDay ordinal suffix (st, nd, rd, th)st
%lTextual day of the week (short form: Mon, Tue, etc.)Mon
%LTextual day of the week (long form: Monday, Tuesday, etc.)Monday
%hHour (12-hour format with leading zero: 01-12)01
%gHour (12-hour format without leading zero: 1-12)1
%HHour (24-hour format with leading zero: 00-23)00
%GHour (24-hour format without leading zero: 0-23)0
%mMinute (00-59)00
%sSecond (00-59)00
%AUppercased AM/PMAM
%aLowercased am/pmam