Skip to content

timezone conversion one hour more than usual #71

@chapman-cc

Description

@chapman-cc

I’m trying to create a TZDate instance and compare it with other dates.
However, it looks like the instantiation from TZDate isn’t handling daylight savings time (DST) correctly.

import { parseISO } from 'date-fns';
import { tz, TZDate } from '@date-fns/tz';

const instantiation = new TZDate('2025-10-04T23:59:00', 'Europe/Copenhagen');

/**
 * TZDate 2025-10-04T22:59:00.000Z {
 *   timeZone: 'Europe/Copenhagen',
 *   internal: 2025-10-05T00:59:00.000Z
 * }
 */

const parsedInstance = parseISO(timestring, { in: tz(iana) });

/**
 * TZDate 2025-10-04T21:59:00.000Z {
 *  timeZone: 'Europe/Copenhagen',
 *  internal: 2025-10-04T23:59:00.000Z
 * }
 */

Based on timeanddate.com’s converter, the conversion suggests a mismatch.
Image

Dependencies

  "dependencies": {
    "@date-fns/tz": "^1.4.1",
    "@date-fns/utc": "^2.1.1",
    "date-fns": "^4.1.0"
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions