Understanding date in javascript when a string of numbers is passed to a Date object

Why, when a string of numbers of different lengths is passed Date in Javascript, sometimes it returns a Date object and sometimes an invalid date.

For instance:

  • new Date ('123456') → Tue Jan 01 123456 00:00:00 GMT + 0530

  • new Date ('1234567') → Invalid date

  • new Date ('999999') → Invalid date

+4
source share
1 answer

, . , Xotic750, Javascript -100 000 000 100 000 000 01 1970 UTC. , "123456" , "1234567" "999999" .

, Date - . , , ..

+2

Source: https://habr.com/ru/post/1675725/


All Articles