title: How to compare 2 dates using Momentjs diff
body: <p>I'm trying to compare 2 dates. If the date received is before the current day (Today) I have to delete the attribute <code>@availabilityBeginDate</code> but if the date received is after the current day I have to save it. I'm writing it in CoffeeScript.</p>
  
  <p>I want to do that with Moment.js and <code>diff</code>. Here is the code I've tried but it doesn't work and I can't figure out why.</p>
  
  <pre><code>if (moment(moment(getCurrentDate()).diff(@availabilityBeginDate)).format("DD MMMM YYYY") &lt; 0) 
      delete @availabilityBeginDate
  </code></pre>
  
  <p>Here is the <code>getCurrentDate</code> method : </p>
  
  <pre><code>getCurrentDate:() -&gt;
    today = new Date
    dd = today.getDate()
    mm = today.getMonth() + 1
    yyyy = today.getFullYear()
    if dd &lt; 10
      dd = '0' + dd
    if mm &lt; 10
      mm = '0' + mm
    today = dd + ' ' + mm + ' ' + yyyy
    return today
  </code></pre>
  
  <p>Here is how I save <code>@availabilityBeginDate</code> :</p>
  
  <pre><code>bidDispoDetails.rows.push({label: 'Début', value: moment(@availabilityBeginDate).format("DD MMMM YYYY")}) if @availabilityBeginDate?
  </code></pre>