Skip to content

Provide way to specify multiple formats when creating a date in UTC. #1596

Open
@DavidRigglemanININ

Description

@DavidRigglemanININ

If trying to parse a date in which you also need to enable it validates correctly (i.e. using strict mode), you can do so with the following

dayjs(it, ["YYYY-MM-DDTHH:mm:ss.SSS[Z]", "YYYY-MM-DDTHH:mm:ss[Z]"], true);

However, if using the UTC plugin, it doesn't seem to allow specifying multiple formats so I can only do

const date = dayjs.utc(it, "YYYY-MM-DDTHH:mm:ss.SSS[Z]", true);

It would be great the behavior of utc could be extended to support multiple formats as well. Or if anyone knows a workaround to get strict validation and UTC both working together, I'd love to hear it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions