What's the difference between JavaScript's getYear() and getFullYear() functions?

前端 未结 3 1452
臣服心动
臣服心动 2021-02-12 02:52

I was working with JavaScript\'s Date object, and somewhere for the first time I needed to extract the year part of the date. What I saw was a weird behavior. It re

3条回答
  •  忘掉有多难
    2021-02-12 03:18

    Its a Y2K thing, basically getYear method returns the year minus 1900.

    so, I encourage to move over to getFullYear & use that instead.

提交回复
热议问题