Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method utc()/format() incorrectly parses the date string 'ddd, MMM D YYYY' #2819

Open
eugenkr opened this issue Jan 24, 2025 · 1 comment
Open

Comments

@eugenkr
Copy link

eugenkr commented Jan 24, 2025

Describe the bug
If your date string format is 'ddd, MMM D YYYY' than dayjs.utc() creates a wrong object, but if you change the format to 'YYYY-MM-DD' it works correctly. Probably it's format() issue. Example:

dayjs.utc('Fri, Jan 28 2025').format('YYYY-MM-DD') => '2025-01-27'
dayjs.utc('2025-01-28').format('YYYY-MM-DD') => '2025-01-28'

Expected behavior
This command dayjs.utc('Fri, Jan 28 2025').format('YYYY-MM-DD') have to result in 2025-01-28

Information

  • Day.js Version 1.11.13
  • OS: MacOS
  • Browser Chrome 131
  • Time zone: GMT+2:00
@eugenkr eugenkr changed the title Method utc() incorrectly parses the date string 'ddd, MMM D YYYY' Method utc()/format() incorrectly parses the date string 'ddd, MMM D YYYY' Jan 25, 2025
@CarlosSenobio
Copy link

I have the same problem when formatting a date to the Brazilian format; it's inverted. For example:

const originalDate = "2025-02-05";

// Formatting the date
console.log(dayjs(originalDate).utc().format("DD/MM/YYYY"));

// Output:
02/05/2025

// Expected:
05/02/2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants