title: Check if JavaScript string represents Date
body: <p>I am stuck with checking if the string represents <code>Date</code>. Currently I have a situation where I need to check if <code>"Tue May 16 2017 00:00:00 GMT+0400 (Georgian Standard Time)"</code> this string represents <code>Date</code>. I wrote the following code:</p>
  
  <pre><code>var tryConvert = new Date(input);
  var tryMonth = tryConvert.getMonth();
  if (!(tryMonth !== tryMonth)) {//checking for NaN
      return true;
  }
  </code></pre>
  
  <p>The problem is that input can be integer <code>96</code> and it successfully returns true. The desired behavior is that it should work only for <code>Date</code> instances, <code>ISO</code> strings <code>/\d\d\d\d\-\d\d\-\d\dT\d\d\:\d\d\:\d\d/g</code> and <code>Date.toString()</code> strings like <code>"Tue May 16 2017 00:00:00 GMT+0400 (Georgian Standard Time)"</code>. How can I achieve this?</p>
  
  <p>To make it more clear here is the full code:</p>
  
  <pre><code>function isDate(input) {
      if (!input) {
          return false;
      }
  
      if (input instanceof Date) {
          return true;
      }
  
      var rx = /\d\d\d\d\-\d\d\-\d\dT\d\d\:\d\d\:\d\d/g;
      var time = rx.exec(input);
  
      if (time) {
          return true;
      }
  
      if (typeof input === 'string' || input instanceof String) {
          var tryConvert = new Date(input);
          var tryMonth = tryConvert.getMonth();
          if (!(tryMonth !== tryMonth)) {
              return true;
          }
      }
  
      return false;
  };
  </code></pre>