Im building a timeclock app with Angular 5. In this app I calculate the total hours using this method.
Chrome:
const start = +new Date(2018-07-24 + ' ' + 14:00);
const elapsed = +new Date(2018-07-24 + ' ' + 14:45) - start;
this.clockedInHours = elapsed / 3600000;
resulting in the total hours clocked in being 0.75
Running the same code in safari returns NaN
I found using the letter 'T' instead of the space when setting the date/time returns number values in safari
const start = +new Date(2018-07-24 + 'T' + 14:00);
const elapsed = +new Date(2018-07-24 + 'T' + 14:45) - start;
this.clockedInHours = elapsed / 3600000;
but instead of getting 0.75 for the total, im getting
4763748.75 in safari
and
4763754.75 in chrome