Solved

MomentJS Check if date has occurred in past

Posted on 2014-10-24
1
1,401 Views
Last Modified: 2014-11-18
I'm trying to check if a date has occurred in the past using MomentJS

      var isToday = new Date();
      var meetingDate = moment(object["meetingdate"]);
      var weeklySubDays = moment().subtract('days', 7);
      var outCome = isToday + meetingDate > weeklySubDays;

Open in new window

0
Comment
Question by:brendanlefavre
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40402675
var meetingDate = moment(object["meetingdate"]);
var outCome = moment().diff(meetingDate,'day') > 7;

Open in new window


more infos :
http://momentjs.com/docs/#/displaying/difference/
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now