Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142410

how to shift a date to the following month (fixed day)

$
0
0

I have a date in javascript that is dd/mm/yyyy format. I wanto to calculate from that date another date with the following requisites: month will be the following from the date chosen (january will shift to february, dicember to january and so on) year will shift accordingly day will be always 16

I am starting from this (ref. this question):

    var CurrentDate = new Date();
    CurrentDate.setMonth(CurrentDate.getMonth() + 1);
    console.log("Date after 1 months:", CurrentDate);

but need to set the day as 16 and to check that the edge situations are considered. Any suggestion on how to go on with this code?

P.S. i'm looking for a solution in Vanilla JS or jQuery with no additional libraries


Viewing all articles
Browse latest Browse all 142410


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>