title: Compare datetimes, see if one hour has passed
body: <p>I am trying to see if one hour has passed since the creation of a token object.
  i am using datetime.utcnow when creating it.</p>
  
  <p>I have tried datetime.compare, and straight up comparing two date times, but it gets the same result no matter what i do.. (not what i want)</p>
  
  <p>If one hour since its creation has passed, the Token should be "consumed", so it is no longer valid.</p>
  
  <p><strong>Token object</strong> </p>
  
  <pre><code>    public int ID { get; set; }
  
      public int UserId { get; set; }
  
      public string Token { get; set; }
  
      public System.DateTime Time_stamp { get; set; }
  
      public Nullable&lt;bool&gt; Consumed { get; set; }
  </code></pre>
  
  <p><strong>My validation method</strong></p>
  
  <pre><code>public bool IsValidToken(string token)
  {
          var tokenEntity = this.GetAll().Where(x =&gt; x.Consumed == false &amp;&amp; x.Token == token).FirstOrDefault();
  
              if (tokenEntity != null)
              {
                  var tokenDate = tokenEntity.Time_stamp;
  
                  var machineDate = DateTime.UtcNow;
  
  
                  var result = DateTime.Compare(tokenDate, machineDate.AddHours(1));
  
                  if (result &gt; 0)
                  {
                      tokenEntity.Consumed = true;
                      this.Update(tokenEntity);
                      return false;
                  }
                  else
                  {
                      return true;
                  }
              }
              return false;
          }
  </code></pre>