dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

dayjs().format('x') result output x characters

Open witlploe opened this issue 2 years ago • 2 comments

Describe the bug Regarding the function of format('x'), the results obtained are inconsistent with expectations. dayjs('2023-09-01T08:12:16.468+00:00').format('x') output:x dayjs('2020-03-25T02:53:51.259Z') output:{$L: 'en', $d: Wed Mar 25 2020 10:53:51 GMT+0800 (中国标准时间), $x: {…}, $y: 2020, $M: 2, …} dayjs('2020-03-25T02:53:51.259Z').format('x') output:x Expected behavior Unix Timestamp in millisecond

Information Day.js Version [1.11.9] OS: [Mac OS 13.4] Browser [Chrome Version 116.0.5845.110] Time zone: [GMT +2]

witlploe avatar Sep 01 '23 08:09 witlploe

You need to add the advancedFormat plugin https://day.js.org/docs/en/plugin/advanced-format

var advancedFormat = require('dayjs/plugin/advancedFormat')
dayjs.extend(advancedFormat)
dayjs('2023-09-01T08:12:16.468+00:00').format('x')

cp3hnu avatar Sep 01 '23 08:09 cp3hnu

You need to add the advancedFormat plugin https://day.js.org/docs/en/plugin/advanced-format

var advancedFormat = require('dayjs/plugin/advancedFormat')
dayjs.extend(advancedFormat)
dayjs('2023-09-01T08:12:16.468+00:00').format('x')

I have the same issue, I added the plugin but the result didn't change

zeinabsayyadi avatar Apr 16 '24 08:04 zeinabsayyadi