JSFiddle - React, Tailwind, and code Playground

by Aya Salama

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<span class="first-date"></span> - <span class="second-date"></span>
<br/><br/>
<span class="first-date"></span> - <span class="second-date"></span>

JavaScript

var  months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
    "Oct", "Nov", "Dec"];
var dateObj = new Date(); //get today's date
var dateObj_7 = new Date(dateObj.getFullYear(), dateObj.getMonth(), dateObj.getDate() + 7 );
var dateObj_14 = new Date(dateObj.getFullYear(), dateObj.getMonth(), dateObj.getDate() + 14 );
//get the month from dateObj_7
var month_7 = dateObj_7.getMonth(); //months from 0-11
//get the month from dateObj_14
var month_14 = dateObj_14.getMonth();
//get the day from dateObj_7
var day_7 = dateObj_7.getDate();
//get the day from dateObj_14
var day_14 = dateObj_14.getDate();
// your wanted format for both days
var next_7_date =  months[month_7] + " " + day_7;
var next_14_date =  months[month_14] + " " + day_14;

$('.first-date').html( next_7_date);
$('.second-date').html( next_14_date);

// or also you can get dates like this
/*
//add 7 days and convert day -> milliseconds and get the correct date
var dateObj_7 = new Date(dateObj.getTime() + 7 * 24 * 60 * 60 * 1000);
//add 14 days and convert day -> milliseconds and get the correct date
var dateObj_14 = new Date(dateObj.getTime() + 14 * 24 * 60 * 60 * 1000);
*/
// if you want to get dat in 2 digits (01, 02, 03 ...etc)
/*
var day_7 = ("0" + dateObj_7.getDate()).slice(-2);
var day_14 = ("0" + dateObj_14.getDate()).slice(-2);
*/