iamkun / dayjs

⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
https://day.js.org
MIT License
46.86k stars 2.29k forks source link

dayjs.utc(dayjs(), 'YYYY') is Invalid Date #2519

Open qiphon opened 10 months ago

qiphon commented 10 months ago

Describe the bug console.log(dayjs.utc(dayjs(), 'YYYY'));

result

M
$D: NaN
$H: NaN
$L: "en"
$M: NaN
$W: NaN
$d: Invalid Date {}
$isDayjsObject: true
$m: NaN
$ms: NaN
$s: NaN
$u: true
$x: {}
$y: NaN

dayjs@1.11.10

hwanyoungChoi commented 10 months ago

What is 'YYYY' used for? If you want to print the year, use the .format() method.

dayjs.utc().format('YYYY')