dayjs("2").format() == '2001-02-01T00:00:00+09:00' ???
See original GitHub issueHi 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:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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