question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dayjs("2").format() == '2001-02-01T00:00:00+09:00' ???

See original GitHub issue

Hi guys. First of all, Thank you for creating and managing this wonderful time library module. I think you are really great people!! I hope one day I can help you to manage this module.

Describe the bug Now I’m trying to change my typescript codes’s time library module from moment.js to dayjs. But I got a strange result like below.

console.log(dayjs("2").isValid())        // true
console.log(dayjs("2").format())        // "2001-02-01T00:00:00+09:00"

I expected it to be invalid and dayjs would throw error. But It didn’t at all. I can’t understand how these result came out.

Could anyone please explain me why these result came out?

Information

  • Day.js Version [1.10.7]
  • OS: [macOS Big Sur 11.4]
  • node: [12.22.3]
  • Time zone: [e.g. GMT-09:00 KST (Korea Standard Time)]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kihyunkimleecommented, Sep 22, 2021

@imwh0im Thanks!

0reactions
imwh0imcommented, Sep 22, 2021

@kihyunkimlee Yes. In addition, the wrong format gives the phrase ‘invalid date’.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Format
Get the formatted date according to the string of tokens passed in. To escape characters, wrap them in square brackets (e.g. [MM] )....
Read more >
AdvancedFormat
Format Output Description Q 1‑4 Quarter Do 1st 2nd ... 31st Day of Month with ordinal k 1‑24 The hour, beginning at 1
Read more >
Format
Get the formatted duration according to the string of tokens passed in. ... dayjs.duration({ seconds: 1, minutes: 2, hours: 3, days: 4, months:...
Read more >
String + Format
If you know the format of an input string, you can use that to parse a date. ... isValid() // true dayjs('1970-00-00', 'YYYY-MM-DD',...
Read more >
Customize
Day.js is very easy to customize. You can create a new locale. var localeObject = {...} // Day.js locale Object, detailed below dayjs.locale('en-my-settings', ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found