momentjs - How to parse this time string with Datatables and moment.js? -


so i'm using datatables , moment.js plugin (https://datatables.net/plug-ins/datarender/datetime). (the string) "invalid date" returned...

{ "data": "last_updated", //source: 2016-11-02 10:32pm gmt render: $.fn.datatable.render.moment( 'yy-mm-dd hh:mmtt gmt', 'dd mmm yy' ) } 

thanks!

that plugin takes one, 2 or 3 arguments. testing seems though date valid i'd suggest passing "ss mmm yy" function. quick example seems work:

moment("2016-11-02 10:32pm gmt").format("dd mmm yy"); // "02 nov 16" 

another issue might date isn't set, it's perhaps worth checking nulls , setting default content. in fact, if you've got momentjs available can replace plugin render function:

"render": function(data){     return (moment(data).isvalid()) ? moment(data).format("dd mmm yy") : "-"; } 

hope helps.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -