I need to get difference between 2 days, not big deal. But when i go from eg: diff days between 2019-06-27 11:00 and 2019-06-30 08:00 (3 days diff) it return 4 days. Every difference > 2 is jumping the 3rd day and returning 1 extra day.
I'm working with Ubuntu 18.04 LTS and tried on current last version of Google Chrome Versión 75.0.3770.100 (Build oficial) (64 bits) I tried momentjs with same problem, then moved to Date object native of javascript and the same problem.
var oneDay=24*60*60*1000;
var firstDay= new Date(pickUpDate[2],pickUpDate[1]-1,pickUpDate[0],0,0,0);
var secondDay= new Date(returnDate[2],returnDate[1]-1,returnDate[0],0,0,0);
days=(secondDay.getTime()-firstDay.getTime())/oneDay;
console.log(days)
//input:pickUpDate[]=["01","07","2019"]
//returnDate[]=["03","07","2019"]
//output: 2
//input:pickUpDate[]=["01","07","2019"]
//returnDate[]=["04","07","2019"]
//output: 4
Date1= moment(pickUpDate+' '+phour,'DD/MM/YYYY HH:mm');
Date2=moment(returnDate+' '+rhour,'DD/MM/YYYY HH:mm');
days=moment.duration(Date2.diff(Date1))/(1000*60*60*24);
console.log(days)
//input:pickUpDate="01/07/2019"
//returnDate="03/07/2019"
//phour="11:00"
//rhour="08:00"
//output: 2.rightdecimals
//input:pickUpDate="01/07/2019"
//returnDate="04/07/2019"
//phour="11:00"
//rhour="08:00"
//output: 4.rightdecimals
//Also tried moment.duration().asDays() and the same history.
No errors on the console
EDIT
Tried same code at Windows 10 and latest Chorme and is working perfectly, hope somebody have some idea what's going on. My day time is (UTC-06:00) Guadalajara, Ciudad de México, Monterrey