title: How fix max number day in Month with Angular?
body: <p>I have a date function with datepicker (with Angular 8), but I have a problem. for example when I enter <strong>36/04/2020</strong>, it saves in the database with a date <strong>05/06/2020</strong>.
  I want when the number of days exceeds the number of days in a month it returns to me the last day (for example in my case it is necessary to enter <strong>30/04/2020</strong>).
  how to fix this and thank's ?</p>
  
  <p>code .ts:</p>
  
  <pre><code>import { NativeDateAdapter, DateAdapter, MAT_DATE_FORMATS, MatDateFormats } from "@angular/material";
  
      export class AppDateAdapter extends NativeDateAdapter {
  
          parse(value: any): Date | null {
              if ((typeof value === 'string') &amp;&amp; (value.indexOf('/') &gt; -1)) {
                const str = value.split('/');
                const year = Number(str[2]);
                const month = Number(str[1]) - 1;
                const date = Number(str[0]);
                return new Date(Date.UTC(year, month, date));
                ;
              }
              const timestamp = typeof value === 'number' ? value : Date.parse(value);
              return isNaN(timestamp) ? null : new Date(timestamp);
            }
  
            createDate(year: number, month: number, date: number): Date {
              return new Date(Date.UTC(year, month, date));
            }
  
            format(date: Date, displayFormat: Object): string {
              if (displayFormat === 'input') {
                let day: string = date.getUTCDate().toString();
                day = +day &lt; 10 ? '0' + day : day;
                let month: string = (date.getUTCMonth() + 1).toString();
                month = +month &lt; 10 ? '0' + month : month;
                let year = date.getUTCFullYear();
                return `${day}/${month}/${year}`;
  
              }
              // new Date(date.toDateString()).getUTCDate(); 
              return date.toDateString();
  
            }
  
         private _to2digit(n: number) {
             return (n);
             //return ('00' + n).slice(-2);
         } 
      }
  
      export const APP_DATE_FORMATS =
      {
         parse: {
             dateInput: {month: 'short', year: 'numeric', day: 'numeric'}
         },
         display: {
             // dateInput: { month: 'short', year: 'numeric', day: 'numeric' },
             dateInput: 'input',
             // monthYearLabel: { month: 'short', year: 'numeric', day: 'numeric' },
             monthYearLabel: 'inputMonth',
             dateA11yLabel: {year: 'numeric', month: 'long', day: 'numeric'},
             monthYearA11yLabel: {year: 'numeric', month: 'long'},
         }
      }
  </code></pre>