|
|
|
|
|
by jasamer
1624 days ago
|
|
I used the JS Date API for the first time a few months ago, and wrote something like date.getYear() + "-" + date.getMonth() + "-" + date.getDay()
in the hope of getting something like "2022-1-4".The actual result for that date is "122-0-2" - not a single component of the date was what I expected. |
|
I'm sure you've read the docs since then but just for the viewers at home:
s/getYear/getFullYear
s/getDay/getDate
getYear is oldfashioned, years since 1900. getDay is day-of-the-week, 0 for Sunday, 1 for Monday, etc