In AngularJS, one could display datetime strings in various formats using date filters:
<p>Date: {{ "2017-02-10T12:10:00.000Z" | date : "fullDate" }}</p>
and that would render:
Date: Friday, February 10, 2017
Is there such a thing as a date filter in React?
AngularJS date filter is used to convert a date into a specified format. When the date format is not specified, the default date format is 'MMM d, yyyy'.
change', function (e) { var value = $("#myInput"). val(); var firstDate = moment(value, "DD/MM/YYYY"). day(0). format("DD/MM/YYYY"); $("#myInput").
You can make use of npm package moment
to achieve what you want.
Install it like:
npm install --save moment
And then import in your React component like:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With