We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
z
Describe the bug When I want to use z as format value, it returns z without transformation
dayjs.extend(utc) dayjs.extend(timezone) // ... export const formatDateTime = ( datetime: string, timezoneStr: string, formatStr: string ): string => { const date = dayjs(datetime).tz(timezoneStr); return ${date.format(formatStr)} ${date.format('z')}; };
test case:
beforeAll(() => { dayjs.extend(utc) dayjs.extend(timezone) }) it('formats with the correct timezone abbreviation', () => { const datetime = '2024-11-18T12:00:00Z'; const timezoneStr = 'Europe/London'; const formatStr = 'YYYY-MM-DD HH:mm:ss'; const formattedDate = formatDateTime(datetime, timezoneStr, formatStr); expect(formattedDate).toBe('2024-11-18 12:00:00 GMT'); // assuming GMT for the timezone });
I've been looking into sources: https://github.com/iamkun/dayjs/blob/dev/src/index.js#L333 but unfortunaltelly lowercase z is not included
Expected behavior z will be transformed correctly according to https://day.js.org/docs/en/plugin/advanced-format
Information
The text was updated successfully, but these errors were encountered:
Try to use advancedFormat plugin
advancedFormat
import advancedFormat from "dayjs/plugin/advancedFormat"; dayjs.extend(advancedFormat);
Normal format function not support z, but you can use advancedFormat plugin to make it support z.
format
Sorry, something went wrong.
No branches or pull requests
Describe the bug
When I want to use
z
as format value, it returns z without transformationtest case:
I've been looking into sources: https://github.com/iamkun/dayjs/blob/dev/src/index.js#L333 but unfortunaltelly lowercase
z
is not includedExpected behavior
z
will be transformed correctly according to https://day.js.org/docs/en/plugin/advanced-formatInformation
The text was updated successfully, but these errors were encountered: