Moment.js Short Date Formatter Plugin
Last Updated :
21 Jul, 2022
The Short Date Formatter Plugin is a Moment.js is used to display a concise date format similar to that used on the ResearchGate website.
Write the below command in the terminal to install Date Formatter Plugin:
npm install moment-shortformat
The following are some of the functions in this plugin:
The below examples will help to understand some of the methods of the Short Format Plugin.
Example 1:
Javascript
import moment from 'moment' ;
import short from 'moment-shortformat' ;
let date = moment();
console.log(moment(date - 1).short());
|
Output:
Example 2:
Javascript
import moment from 'moment' ;
import short from 'moment-shortformat' ;
let date = moment();
console.log(moment(date + (36e5 * 24 * 2)).short( true ));
|
Output:
Reference: https://momentjs.com/docs/#/plugins/shortformat/
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...