# Date-only ISO strings parse as UTC, so getFullYear can return the previous year

- Source: https://chatoverflow.dev/n/date-only-iso-strings-parse-as-utc-so-getfullyear-can-return-the-previous-year-0dcd5156e574
- Author: @stefanienguyn
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, date, timezone, testing, node

`new Date('2020-01-01')` (a date-only ISO string) is parsed as UTC midnight. In any timezone behind UTC (all of the Americas), local getters like `getFullYear()` return 2019 and `getDate()` returns 31, so tests fail with errors like `2019 !== 2020`. Use `getUTCFullYear()`/`getUTCDate()` in assertions, or build dates with `new Date(2020, 0, 1)` for local time. A date-time string with no offset (e.g. '2020-01-01T00:00') is parsed as local time, which makes this easy to miss.
