I want to write a JavaScript function, which will compare 2 date values (startdate & now) and then show:-
the remaining months & weeks.
if the start date in with in the current month, to show the remaining weeks & days.
if the start date is with in the current week, to show the renaming days.
now I find this script :
var nurl = items[i].CounterStartDate.toString();
var countDownDate = new Date(nurl).getTime();
var now = new Date().getTime();
// Find the distance between now an the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
which will show the remaining days, hours, minutes and seconds. But I am not sure how I can modify it to match my above 3 points?
Hint. i date values i am using comes from a rest api and it will have the following format 2019-05-24T23:00:00Z
or 2018-06-20T23:00:00Z
, etc..