moment.js - Deprecation warning: moment construction falls back to js Date.

moment.js - Deprecation warning: moment construction falls back to js Date.

crush123crush123 Posts: 417Questions: 126Answers: 18
edited May 2016 in Editor

I have been using this add-on for a while now, but have been getting Deprecation warning messages, (though pages seem to work ok) when i use it to apply conditional logic on my table render

I was looking on the site for some pointers, but can;t seem to find any reference to this library any more.

BTW the warning appears if I use the following in my ajax data source

->getFormatter( 'Format::datetime', array(
            'from' => 'Y-m-d H:i:s',
             'to' =>   'j M Y H:i'.....

as if I remove these lines, it runs ok

error points to /DataTables-1.10.11/js/jquery.dataTables.min.js:18:301

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Could you show me your Editor's Javascript initialisation please? That is where MomentJS is used, not in the PHP.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    not quite sure what you need Allan,

    I have a data source (ajax) php page to get the json data.

    I have a page to display the results with a datatable, (but in this instance no editor)

    I am using the json data in my table with moment to (for example) render a button in my table if certain criteria are met

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I'd assumed you were using Editor since the PHP you show above is part of the Editor PHP options.

    DataTables core doesn't use MomentJS at all. I'd need to be able to see your code to understand where you are using MomentJS to understand why there is a deprecation warning.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18
    edited May 2016

    I understand.

    I sometimes have an admin page and a 'public' page using the same ajax source, but with the public version with no editing option, just the datatable with some of the fields displayed

    i created a version of this for a question i raised in another thread, i will edit the ajax source to create the warning

    http://test3.forthwebsolutions.com/vanilla_events.php

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    In your code for a column's render callback you have:

    moment(row.tblevent.EventDate).format("YYYYMMDDTHHmm") + '00

    Clicking the link in the Moment warning it says:

    moment construction using a non-iso string is deprecated.

    Since your EventDate value isn't an ISO value, Moment is giving that warning. The link it gives notes how change your use of Moment.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    i have now removed the column in question, so the only one with moment() is the eventdate column which simply displays (moment(data));

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    return (moment(data));

    Where data is 6 Jun 2016 18:30.

    Which is not an ISO8601 string. Hence the warning from moment still applies. I'm not entirely sure I understand the issue with that?

    Allan

This discussion has been closed.