title: How to validate dates without leading zero on day and month?
body: <p>I need to validate a precise date format in php. </p>
  
  <p>In my case the optimum date format should be: e.g. <code>1/1/2017</code> (without leading zeros) and the code should allow me to avoid the rest of date's format.</p>
  
  <p>The following code is what i wrote but with no result:</p>
  
  <pre><code>if(preg_match("/([1-9]|[1-2][0-9]|3[0-1]-([1-9]|1[0-2])-^[0-9]{4})$/", $date){
      // insert into etc. etc....
  }else{
      // update etc. etc....
  }
  </code></pre>
  
  <p>The problem is that the code doesn't properly validate the date; it accepts every kind of date format.</p>