![]() |
JavaScript has various useful packages for working with date and time. One such library is DayJS, which provides a simple and proper way to manipulate, format, and parse dates in JavaScript applications. Prerequisites:Steps to Create Application and Installing PackageStep 1: Create a new folder for your project and navigate into it.mkdir day-JS Step 2: Initialize npm to create a package.json file.npm init -y Step 3: Install dayjs package using below command.npm install dayjs Project Structure:![]() Project Structure Approach
Updated Dependencies: "dependencies": { Example 1: The example below shows the use of DayJS Library to work with Date and Time in JS.
Output: ![]() Output Example 2: In this example, we are using the DayJS library to calculate the difference in days between two dates. We import DayJS using require(‘dayjs’), create two date objects, calculate the difference with date2.diff(date1, ‘days’), and then display the result along with the formatted dates.
Output: ![]() |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 16 |