#4161·date-fns

Transpose function not behaving as documentation states

Author: filipe-bonito-tlgCreated Feb 16, 2026Updated Aug 24, 2026

There is an issue with the transpose function

The problem

Code demonstrating the problem

My local computer timezone is set to America/New_York

import { transpose } from 'date-fns';
import { UTCDate } from "@date-fns/utc";

const date = new Date(2022, 6, 10)
//=> 'Sun Jul 10 2022 00:00:00 GMT-0400 (Eastern Daylight Time)'

transpose(date, UTCDate)
//=> 'Sat Jul 09 2022 20:00:00 GMT-0400 (Eastern Daylight Time)'

Actual behavior

transpose returns Sat Jul 09 2022 20:00:00 GMT-0400 (Eastern Daylight Time)

Expected behavior

For transpose to return Sun Jul 10 2022 00:00:00 GMT+0000 (Coordinated Universal Time) as per the documentation

Debug information

  • date-fns version: 4.1.0
  • Browser/Node.js version: Chrome 144.0.7559.133

Documentation states:

Create July 10, 2022 00:00 in locale time zone

const date = new Date(2022, 6, 10)
//=> 'Sun Jul 10 2022 00:00:00 GMT+0800 (Singapore Standard Time)'

Transpose the date to July 10, 2022 00:00 in UTC

transpose(date, UTCDate)
//=> 'Sun Jul 10 2022 00:00:00 GMT+0000 (Coordinated Universal Time)'