Chartjs-How to filter chart.js by month

0👍

use Date objects, that are provided by ECMAScript 5

to create object representing current date just call

    const now = new Date()

and for example, i will take one of the strings in your array:

    const dateFromString = new Date("2019-12-29T10:42:25Z")

also, you can set months

    var d = new Date();
    d.setMonth(d.getMonth() - 3);

you can do many things with such objects, they have many methods.
Also, you can compare date objects

    now > dateFromString // will return true or false

and to get miliseconds since 1970-01-01 use this

    const a = new Date()
    a.getTime()
    //1577724851239

Leave a comment