How to increase the day in this date string '2022-05-06' in JS? It can be both native and moments solution. I checked add method in moment but looks like I am doing something wrong and it doesn't work:
const date = '2022-05-06'
console.log(moment(date).add(1, 'days'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.3/moment.min.js"></script>
CodePudding user response:
You should parse string to moment object properly:
const date = '2022-05-06'
const newDate = moment(date,'YYYY-MM-DD').add(1, 'days');