Open In App

Moment.js Short Date Formatter Plugin

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:




import moment from 'moment';
import short from 'moment-shortformat';
  
let date = moment();
console.log(moment(date - 1).short());

Output:

 

Example 2:




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/

Article Tags :