title: Date format for Spanish speakers - returning NaN or Invalid Date
body: <p>I have an Angular application</p>
  
  <p><strong>Goal</strong>: I want a user to be able to type in Spanish format for a date (DD/MM/YYYY). It should display in Spanish format to the user, but convert it back to English behind-the-scenes when sending the data to the Database</p>
  
  <p><strong>Problem</strong>: If they type something larger than 12 for the first 2 digits, then JavaScript Date complains that it's NaN.</p>
  
  <p><strong>What I tried</strong>: I looked up documentation and found the method <code>toLocaleDateString</code> and <code>toLocaleString</code>. However this is used on a Date. And if a date becomes <strong>NaN</strong> then I don't see how the method would work? I tried it out anyways but it just says <strong><em>Invalid Date {}</em></strong>
  I am in central time zone if it matters.</p>
  
  <p><strong>TypeScript</strong>:</p>
  
  <pre><code>dateEnter(data) {
      let dateSpanish = new Date(data).toLocaleDateString;
      let dobForDB = (this.localeId == "es") ? this.myMethod(new Date(dateSpanish) : data;
  }
  
  myMethod(date: any) {
      let year = date.getFullYear();
      let day = date.getDate();
      let month = date.getMonth() + 1;
      let dateString = (this.localeId == "es") ? day.toString() + "/" + month.toString() + "/" + year.toString().substring(0, 4) : month.toString() + "/" + day.toString() + "/" + year.toString().substring(0, 4);
      return dateString;
  }
  </code></pre>