dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

Invalid parsing

Open kverty opened this issue 9 months ago • 3 comments

Describe the bug dayjs function ignores provided format.

let test = dayjs('12/01/1996', 'DD/MM/YYYY')

console.log(test.format())

// "1996-12-01T00:00:00+03:00"

Expected behavior Expected result is "1996-01-12T0:00:00+03:00"

Information

  • Day.js Version: 1.11.11
  • OS: Windows 11
  • Browser: chrome, 64 bit
  • Time zone: GMT+03:00
  • I just run it in jsfiddle

kverty avatar May 13 '24 17:05 kverty

I have the same issue


let test = dayjs('03-04-2024', 'DD-MM-YYYY');
console.log(test.toDate()); 
// 2024-03-04T03:00:00.000Z 
// the correct is 2024-04-03T03:00:00.000Z

Information

  • Day.js Version: 1.11.11
  • OS: MacOs
  • Browser: chrome, 64 bit
  • Time zone: GMT+03:00

jorgefo avatar Jun 02 '24 15:06 jorgefo

Did you import custom-parse-format?

joaoGabriel55 avatar Jun 06 '24 20:06 joaoGabriel55

Custom parse format not working correctly.

const date = dayjs("13-12-1999", { format: "DD-MM-YYYY" }, true); // treats 13 as month

Check this: https://runkit.com/embed/w7op0120g88z

tonytkachenko avatar Jul 13 '24 08:07 tonytkachenko