the 1 st one which get using the id has format
var checkindate = $('#check-in').text();
28-07-2011
then i get the current date using
var now = new Date();
and it has the format
Wed Jul 20 2011 19:09:46 GMT+0530 (IST)
i want to get the date difference from these two dates . in this case it is 8
. i searched a lot and could not find an answer , please help……. :'(
You can parse the initial date, feed it to a date object, substract it with the current time to get a millisecond difference, and then divide it by the number of milliseconds in a day.
At the time of writing this gives -7.5. It’s a negative number because the date is in the future. If you want a positive number, just swap the variables in the substraction. If you want a round number, just use Math.round.