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

Support for different Date format for date column type #16

Closed
kaushik-xs opened this issue Jul 2, 2020 · 4 comments
Closed

Support for different Date format for date column type #16

kaushik-xs opened this issue Jul 2, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@kaushik-xs
Copy link

Currently the date column type supports only yyyy-mm-dd. Is there a way to support other date formats (mm-dd-yyyy or dd-mm-yyyy)?

@cscan cscan added the enhancement New feature or request label Jul 4, 2020
@cscan
Copy link
Owner

cscan commented Jul 4, 2020

No easy way to do this, but you may customize the conversion between showing text and value by providing toText and toValue function.

@cscan cscan closed this as completed Jul 4, 2020
@cscan cscan reopened this Jul 4, 2020
@kaushik-xs
Copy link
Author

kaushik-xs commented Jul 4, 2020

@cscan This is cool. I didn't know that there is such an option. Let me try it (toValue and toText) out and get back

@kaushik-xs
Copy link
Author

kaushik-xs commented Jul 5, 2020

This worked.

convertDateToText(value) {
    return moment(value, 'YYYY/MM/DD').format('MM/DD/YYYY')
},
convertDateToValue(text) {
    return moment(text, 'MM/DD/YYYY').format('YYYY/MM/DD')      
}

One more point to note, only if the date format is in yyyy/mm/dd the sorting of the column works.

@cscan
Copy link
Owner

cscan commented Jul 7, 2020

Great! I close this ticket then

Yes, the sorting now only treats the date string as text

@cscan cscan closed this as completed Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants