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

Sorting by 'last hit' doesn't work for all date formats #48

Open
michaelroper opened this issue Dec 1, 2016 · 6 comments
Open

Sorting by 'last hit' doesn't work for all date formats #48

michaelroper opened this issue Dec 1, 2016 · 6 comments

Comments

@michaelroper
Copy link

Sorting redirects or statistics by 'Last Hit' doesn't seem to work properly for me, possibly due to the date format that I use in the admin being dd/mm/yyyy format.

Example of behaviour: https://cl.ly/iIOe

@khalwat
Copy link
Contributor

khalwat commented Jan 21, 2017

So it looks like we have two choices:

  1. I can force the date / time display into a specific format, and sorting will work

  2. I can let you keep the localized date format, and sorting won't work

I'm not sure which is best, but I'm leaning towards #1

@michaelroper
Copy link
Author

I'd be happy with option 1, i'd prefer it to work even if the dates look a little wonky.. ;)
Would that just be reformatting the dates on the client side, or how they are actually saved in the DB?

@khalwat
Copy link
Contributor

khalwat commented Jan 21, 2017

The dates are just stored as a DateTime which is agnostic about formats. The problem is that I'm using the Craft datetime Twig filter, which outputs a DateTime in your preferred locale format.

Which wouldn't normally be a problem, except that the DataTables script I use for displaying them apparently only understands and parses dates in US and ISO formats.

So we either display the dates in a format that isn't what your locale prefers, or we can't sort them properly. There's a third option that I've used before, but it's hacky, and I want to avoid it.

@michaelroper
Copy link
Author

Was just having a look at that DataTables plugin - it does seem to take plugins for sorting dates in different formats (https://datatables.net/plug-ins/sorting/) - how hard would it be to load that in if the date format is dd/mm/yyyy?

@carlcs
Copy link

carlcs commented Mar 21, 2017

@khalwat DataTables allows to set a data-order attribute.
https://datatables.net/manual/data/orthogonal-data#HTML-5

@khalwat
Copy link
Contributor

khalwat commented Mar 22, 2017

@carlcs yeah but I also need to put support in the db records to store this information, so that they are processed in the desired order

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