What is the purpose of moment.js?

0

I bought a new bootstrap template for my system, and it came with an enclosed deal that returns me multiple alerts, moment.js.

From what I've come to understand, it's like a client-side validation library with language support and conversion of some date formats, and I do not understand anything else.

Example:

I have a daterange to generate reports, and when I activate this daterange, the moment notifies my console:

  

Deprecation warning: moment (). subtract (period, number) is deprecated.   Please use moment (). Subtract (number, period).

But the code works, and if I correct this informed warning, the daterange stops working as it should.

The question is:

  

What does moment.js actually do?

     

What can I do with it?

Note: I ask this because I did not really see any utility in it, and several templates come with it docked, but I believe I'm wrong about it and probably it should be useful.

    
asked by anonymous 14.09.2017 / 20:59

1 answer

1

This message indicates that whoever created the template used discontinued commands from moment.js :

  

Deprecation warning: moment (). subtract (period, number) is deprecated. Please use moment (). Subtract (number, period).

Moment.js is a lib used to work with date and time, their API allows you to make calculations and formatting easier.

If you are issuing these warnings then you must ask the template developer to make the necessary adjustments, he probably wrote the first versions of the template using the code as an older version of moment.js, when he was upgraded moment.js he did not notice the warnings.

This specific message you mentioned is mentioned in link

  Before version 2.8.0, the moment # subtract (String, Number) syntax was also supported. It has been deprecated in favor of moment # subtract (Number, String).

Then change the code similar to this:

 moment().subtract('seconds', 1); // Deprecated in 2.8.0

For something like this:

 moment().subtract(1, 'seconds');
    
14.09.2017 / 21:13