Cannot get datetime.js plugin to work

Cannot get datetime.js plugin to work

mheptinstallmheptinstall Posts: 3Questions: 1Answers: 0
edited November 2016 in Free community support

I am trying to use the datetime.js plugin to format my dates, using the example on the plugin page it doesn't appear to be working. What am I doing wrong?

https://jsfiddle.net/pp4nn5L6/

Initializing the second table in that way also doesn't display the pager and other dom elements.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,940Questions: 1Answers: 10,755 Site admin
    Answer ✓

    The columns array is zero index like all arrays in Javascript, so visible column 1 is actually index 0: https://jsfiddle.net/pp4nn5L6/1/ .

    The problem you are seeing in that updated example is that Moment doesn't appear to like the time part: https://jsfiddle.net/pp4nn5L6/2/ . I'm not immediately sure why not!

    Allan

  • mheptinstallmheptinstall Posts: 3Questions: 1Answers: 0
    edited November 2016

    Could this be a bug with the plugin? The below works fine so moment is parsing it correctly. If I specify that format with the plugin it comes back with invalid date.

    alert(moment("2019-04-01T00:00:00", "YYYY-MM-DDTHH:mm:ss").format("Do MMM YYYY"));

  • mheptinstallmheptinstall Posts: 3Questions: 1Answers: 0

    Looking at it again I needed to change it to this:

    render: $.fn.dataTable.render.moment( 'YYYY-MM-DDTHH:mm:ss', 'D MMM YYYY')

  • allanallan Posts: 64,940Questions: 1Answers: 10,755 Site admin

    Thanks for the update - you are absolutely correct. I missed that myself. Too much code floating around in my head ;-).

    Allan

This discussion has been closed.