An warware: bambancin javascript tsakanin ranaku biyu

Babban matsalar da ke da alaฦ™a da bambanci tsakanin kwanakin biyu ita ce ฦ™ila ba za su kasance a yankin lokaci ษ—aya ba.

var date1 = new Date(2018, 11, 24);
var date2 = new Date(2018, 11, 30);
var diffDays = date2.getDate() - date1.getDate();

Wannan lambar tana ฦ™irฦ™irar sabbin abubuwa guda biyu na Kwanan wata, ษ—aya don Disamba 24th, 2018 da ษ—aya don Disamba 30th, 2018. Daga nan ne gano bambanci tsakanin waษ—annan kwanakin biyu ta hanyar .getDate().

Math tare da kwanakin

var kwanan wata = sabon Kwanan wata (); // 1/1/0001 var date2 = sabon Kwanan wata (); // 12/31/9999

Shafi posts:

Leave a Comment