JQuery Moment Subtract Days to Date Example

Jquery

Nicesnippets

503

15-06-2021


Hi Guys,

In this example,I will learn you how to subtract days to date in moment js.you can easy amd simply subtract to days to date in moment js.

Here, i will give you simple example of jquery moment js subtract() method for subtract days to date.let's bellow the example

Example :


<!DOCTYPE html>

<html>

<head>

<title>JQuery Moment subtract Day Example - Nicesnippets.com</title>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" crossorigin="anonymous"></script>

</head>

<body>

<h1>JQuery Moment subtract Day Example - Nicesnippets.com</h1>

</body>

<script type="text/javascript">

var startdate = '15-06-2021'

var newDate = moment(startdate, "DD-MM-YYYY").Subtract(4, 'days').format('DD/MM/YYYY');

console.log(newDate);

</script>

</html>

output

11/06/2021

It will help you...


Recommended Posts