I have been working with dates and realized these 2 commands Date(d.getTime())
and new Date(d.getTime())
are different.
When I run this snippet:
var d = new Date(2016,11,12);
console.log(Date(d.getTime()));
console.log(new Date(d.getTime()));
I have this result:
(index):68 Thu Dec 12 2019 18:02:41 GMT-0300 (Horário Padrão de Brasília)
(index):69 Mon Dec 12 2016 00:00:00 GMT-0200 (Horário de Verão de Brasília)
Why are they different?
I have tried to find some answers but I find none. These are some of references I have gone through:
Difference between Date(dateString) and new Date(dateString)
Why we can't call methods of Date() class without new operator