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

Dates not sorting properly #207

Open
skykep opened this issue Oct 28, 2020 · 5 comments
Open

Dates not sorting properly #207

skykep opened this issue Oct 28, 2020 · 5 comments

Comments

@skykep
Copy link

skykep commented Oct 28, 2020

Date sorting is not working as intended. Single-digit months are being weighed higher than double digit.
For example, a descending order will go as follows:
6/1/2020
5/1/2020
4/1/2020
3/1/2020
11/1/2020
10/1/2020

@skykep
Copy link
Author

skykep commented Oct 28, 2020

If I format the date/time a little bit with moment, it'll sort properly (sort of).
It sorts from left to run, so the year needs to be first, then month, then day...and so on. If using 12-hour mode with an am/pm appended at the end, it will actually put 8:26am later than 8:35pm.

@mfridman
Copy link

Similar deal with the MM-DD-YYYY format. I didn't bother playing around with the existing JS.

Screen Shot 2020-11-12 at 10 56 53 PM

@skykep any chance you have a copy/paste solution 😛

@skykep
Copy link
Author

skykep commented Nov 13, 2020

Are you saying you prefer the dashes instead of slashes?
I got around my problem by formatting it using moment.
Try formatting your dates using moment().format('L'); If you need the dashes, that may not work.

@mfridman
Copy link

Ahh, I thought it supported both dashes or slashes since the website example used both:

Screen Shot 2020-11-13 at 11 14 12 AM

But as you mentioned, can be solved by tweaking the underlying parser.

@skworden
Copy link

skworden commented May 5, 2021

As a workaround - you can convert the date to seconds and then use that value in the data-sort attribute. See docs.

<td data-sort='1620178326325'>05/04/2021</td>

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

3 participants