Custom sort order question

Custom sort order question

Boilermaker80Boilermaker80 Posts: 19Questions: 6Answers: 0

I have two columns in a DataTable that contain FAT filesystem dates formatted for US users like this: 11/16/2015 10:56:00

Naturally when I sort these columns they're sorted as text. How can I sort them by date and time as the user would expect?

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @Boilermaker80 ,

    We use Moment.js, as it's excellent for all time/date based operations. See blog post here.

    Cheers,

    Colin

  • Boilermaker80Boilermaker80 Posts: 19Questions: 6Answers: 0
    edited April 2019

    Thanks! That works great. I noticed in the blog post that it's possible to download Moment.js as part of the DataTables CDN download, but don't see an option to do that on the Downloads page. How would that be done?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @Boilermaker80 ,

    Excellent, glad all working. The datetime-moment.js is on the CDN, but Moment.js is third-party so you'll need to download that from their site (I tend to use here).

    Cheers,

    Colin

This discussion has been closed.