jQuery Tutorial
Lets see how to add the required number of days with current date in jquery,
<script type='text/javascript'> $(document).ready(function () { var Num_of_days = 2; var d = new Date(); var toDate = new Date(); toDate.setDate(d.getDate() + Num_of_days); alert(toDate); }); </script>
This code provides the updated date which is addition of provided number days with today's date as alert message while loading the web page in web browser.
Lets see how to add the required number of days with specific date in jquery,
<script type='text/javascript'> $(document).ready(function () { var Num_of_days = 2; var d = new Date(2019,11,13); var toDate = new Date(); toDate.setDate(d.getDate() + Num_of_days); alert(toDate); }); </script>
This code provides the updated date '2019-11-15' which is addition of provided number days with specific date as alert message while loading the web page in web browser.
Lets see how to subtract the required number of days with current date in jquery,
<script type='text/javascript'> $(document).ready(function () { var Num_of_days = 2; var d = new Date(); var toDate = new Date(); toDate.setDate(d.getDate() - Num_of_days); alert(toDate); }); </script>
This code provides the updated date which is subtraction of provided number days with today's date as alert message while loading the web page in web browser.
Lets see how to subtract the required number of days with specific date in jquery,
<script type='text/javascript'> $(document).ready(function () { var Num_of_days = 2; var d = new Date(2019,11,13); var toDate = new Date(); toDate.setDate(d.getDate() + Num_of_days); alert(toDate); }); </script>
This code provides the updated date '2019-11-11' which is subtraction of provided number days with specific date as alert message while loading the web page in web browser.
« Previous Next »jQuery Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page