Here is my code.
var today = new Date();
var reqDate = new Date(today.getFullYear(),today.getMonth()-3, today.getDate());
var day = today-reqDate;
I want the 'day' should be something around 90; but it gives as some long integer.
Here is my code.
var today = new Date();
var reqDate = new Date(today.getFullYear(),today.getMonth()-3, today.getDate());
var day = today-reqDate;
I want the 'day' should be something around 90; but it gives as some long integer.
The long integer is the number of milliseconds since midnight Jan 1, 1970. So in order to get the number of days you need to divide it. Code below:
var days = day/(1000*60*60*24);
You have got value in day variable as milliseconds, so divide it by 1000*60*60*24 to get day count.
Another thing, it will be a decimal value.
So you have to discard fraction value using floor
function.
var days = Math.floor(day/(1000*60*60*24));