Inconsistent Date.prototype.getTime() value across different Node.js versions #29900
Closed
Description
- Version: 10.16.3
- Platform: Windows 10 1809 (build 17736.805), 64 bit OS
Bug description
The return value of Date.prototype.getTime() is not consistent with different versions of NodeJS.
It seems that the problem started since NodeJS version 10.4.0
To reproduce
Run following code with different NodeJS verions:
const MAX_DATE = new Date(2000, 0, 1);
let date = new Date(1800, 0, 1);
while (date < MAX_DATE) {
console.log(date.toISOString() + '\t' + date.getTime());
date = new Date(date.getFullYear() + 1, 0, 1);
}
Results from my computer:
date_nodejs_v8.16.1_data.txt
date_nodejs_v10.3.0_data.txt
date_nodejs_v10.4.0_data.txt
date_nodejs_v10.16.3_data.txt
Expected behavior
I think that return value of Date.prototype.getTime() should be the same regardless of NodeJS version.
Addition information:
Output of following code:
console.log((new Date()).toString())
console.log((new Date()).toLocaleString())
console.log((new Date()).getTimezoneOffset())
with Node.js version 8.16.1:
Wed Oct 09 2019 11:22:47 GMT+0200 (Central Europe Daylight Time)
2019-10-9 11:22:47
-120
with Node.js version 10.16.3:
Wed Oct 09 2019 11:24:07 GMT+0200 (Central European Summer Time)
10/9/2019, 11:24:07 AM
-120
Activity