Skip to content
New issue

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

Convert a selected date range in Flatpickr #201

Open
MateusJSouza opened this issue Sep 19, 2022 · 0 comments
Open

Convert a selected date range in Flatpickr #201

MateusJSouza opened this issue Sep 19, 2022 · 0 comments

Comments

@MateusJSouza
Copy link

MateusJSouza commented Sep 19, 2022

Is there any way to convert the date selected by Flatpickr itself?
For example:

I select the date in the range of September 5, 2022 to September 12, 2022.

I can get my date through onChange:

onChange={([start, end]) => {
if (start && end) {
    setStartDate(start.toLocaleDateString('pt-BR', {
        year: 'numeric',
        month: '2-digit',
        day: '2-digit',
    }))
    setFinalDate(end.toLocaleDateString('pt-BR', {
        year: 'numeric',
        month: '2-digit',
        day: '2-digit',
    }))
}

After that, my date comes like this:
Start date: 09/12/2022
End date: 09/05/2022

Anyway, what I would like to do is convert this received date into something like this: 2022-09-12 and 2022-09-05. Is there a way to do this using Flatpickr?

I tried to use parseDate as it is in the documentation, but I couldn't and I don't know if it would work for my context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant