I have these date variables
minVal = new Date(parseInt(dateArr[2]), parseInt(dateArr[0]) - 1, parseInt(dateArr[1]), 00, 00, 00);
maxVal = new Date(parseInt(dateArrTo[2]), parseInt(dateArrTo[0]) - 1, parseInt(dateArrTo[1]), 23, 59, 59);
I use them to draw charts.
I need to differentiate between two things:
- During 30 days charts.
- After 30 days charts.
Thus, I need to know the different between these dates in days
I tried to do this:
if ((maxVal.getMonth() - minVal.getMonth()) == 0)
It works with some values and doesn't work with some values. For example, if the minimum date is 29 January 2014
and the maximum date is 01 February 2014
it doesn't work.
I know that because I am calculating the months.
But I don't know how to calculate the days
I know that getDate()
function retrieves the days number but I really couldn't know how to use it.
your help is appreciated