If you plan to build a new web application, we recommend the
day.js library for handling tasks related to date and time. In this article, we will learn to use
day.js and the advantages of day.js.
Let’s install day.js through NPM. So run the below command in the terminal
npm install dayjs
Once you install it you can import it in your app. If your project based on react then you need to import it by following,
import * as dayjs from 'dayjs';
If your project is based on node.js then you need to import it by following,
const dayjs = require('dayjs');
You can also use CDN in the HTML document for adding day.js into it. In this case copy and paste below code in your HTML page.
<script src=" https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.5/dayjs.min.js"></script>