0

I am trying to create a to-do app in react-redux, in that I want to compare date and time if date and time exceed the current date, then I want to pass data to pastReminders otherwise remain in upcoming reminders how should I update the react part and in this I am required to update state in redux also.

I am not getting the approach for this. I have reminders on an array of the object where all my data is stored.Till now I have done this:

const { reminders } = this.props;
       reminders.forEach(function (data) {
       var userTime = data.scheduled_datetime;
       var now  = moment().format();
       if(userTime > now ) {
            var userId = data.id;
            console.log(userId);
}
Vikrant
  • 4,920
  • 17
  • 48
  • 72
  • 4
    this is not related to `reactjs`, and instead of using `moment` to get the current date and time you can use `new Date()` and use `getTime()` to get the milliseconds and compare the milliseconds. – Mayank Shukla May 08 '17 at 06:48
  • Possible duplicate of [Compare two dates with JavaScript](http://stackoverflow.com/questions/492994/compare-two-dates-with-javascript) – Mayank Shukla May 08 '17 at 06:52

0 Answers0