AngularJS Date Filter in React

In AngularJS, you can display datetime strings in different formats using date filters:

<p>Date: {{ "2017-02-10T12:10:00.000Z" | date : "fullDate" }}</p>

and it will do:

Date: Friday, February 10, 2017

Is there such a thing as a date filter in React ?

+4
source share
1 answer

You can use the npm package momentto achieve what you want.

Install it like this:

npm install --save moment

And then import into your React component, for example:

import moment from 'moment';

You can use it like:

const date = new Date();
const formattedDate = moment(date).format('DD-MMM-YY HH:mm:ss');

Docs

+5
source

Source: https://habr.com/ru/post/1669461/


All Articles