There are two variables:

var last_state_tim_strt = moment(last_state['TimStrt'], 'YYYYMMDDHHmmss').valueOf(); var current_state_tim_strt = moment(state['TimStrt'], 'YYYYMMDDHHmmss').valueOf(); 

How to compare by date?

  if (moment(last_state_tim_strt, 'YYYYMMDD', true).format() == moment(current_state_tim_strt, 'YYYYMMDD', true).format()){ /* ... */ } 

    1 answer 1

    Moment.js provides methods for comparing dates - isBefore (), isAfter () and isSame (). According to their names, they return a boolean value if one of the dates was before, after, or they are equal. An example of using isAfter () is shown here.

    • I did this if (moment (last_state_tim_strt) .isSame (current_state_tim_strt, 'day')) - Pantera