How to Subtract 7 Days from Current Date with MomentJS? Last Updated : 28 Aug, 2024 Comments Improve Suggest changes Like Article Like Report The article is all about how can we get the 7 days subtracted date from the given date. for eg: if the given date is 28-08-2024 then it should print 21-08-2024, that is the exactly subtraction of the seven day from the given day. These are the following approaches:Table of ContentUsing the subtract() MethodUsing the add() Method with a Negative ValueUsing the subtract() MethodIn Moment, the subtract() method. Of all the ways we have seen to subtract days off a date, the js is the simplest. The days to be subtracted can be mentioned along with the unit of time that is, days, months or years.Example: This example shows the use of substract() method. JavaScript const moment = require("moment"); const date = moment().subtract(7, "days"); console.log(date.format("YYYY-MM-DD")); Output:2024-08-21Using the add() Method with a Negative ValueAnother way to subtract days is to use the add() method with a negative value. This approach is less common but still effective.Syntax:moment().add(amount, unit);Example: This example shows the use of add() method. JavaScript const moment = require("moment"); const date = moment().add(-7, "days"); console.log(date.format("YYYY-MM-DD")); Output:2024-08-21ConclusionMoment. The js presents several ways through which one can transform dates and it’s very easy to remove some days from a given date. No matter by using the subtract() method, the add() method with a negative parameter or cascaded operations, Moment. js has a rather effective approach as regards the treatment of date. These issues have been described in this article and the following sections are dedicated to different ways of how the current date can be subtracted by 7 days along with an example of output of each way. Comment More infoAdvertise with us Next Article How to Subtract 7 Days from Current Date with MomentJS? S savita8z3a3 Follow Improve Article Tags : JavaScript Web Technologies Moment.js Similar Reads How to Format Date and Subtract Days Using Moment.js? Moment.js is useful in performing date computation and formatting in JavaScript applications. It provides a simple and intuitive API for parsing, validating, manipulating, and formatting dates. we are going to subtract days and format that. These are the following approaches to formatting dates and 2 min read How to Remove Time From Date with Moment.js? Moment.js is a widely used JavaScript library for managing and manipulating dates and times. It simplifies complex date operations and makes it easier to work with dates in a consistent format. One common task is to extract just the date portion from a full timestamp, ignoring the time part. This is 2 min read How to Parse String to Date with MomentJS? Moment.js is the date library in JavaScript that provides parsing, validation, manipulation, and formatting of dates and times. It has several methods to parse strings into date objects, accommodating various formats and time zones. Run the below command before running the code in your local system: 2 min read How to Compare Dates with Moment.js? Moment.js is a popular JavaScript library that developers use for parsing, manipulating, and formatting dates and times. It provides a range of methods to compare dates, making it easier to handle various date-related tasks. With Moment.js, you can use methods like isBefore, isAfter, diff, and isSam 3 min read How to Format Date with Moment.js? Formatting dates is essential for presenting date and time information in a way that's readable and useful for users. Moment.js provides several methods for formatting dates from simple and predefined formats to more complex and localized representations.Below are different approaches:Table of Conte 2 min read Like