title: Convert date strings in an array to datetime objects
body: <p>how can I loop through an array and convert all date field to a date object?</p>
  
  <p>I have an array;</p>
  
  <pre><code>array (size=37)
    'id' =&gt; string '12' (length=3)
    'name' =&gt; string 'Jack' (length=6)
    'surname' =&gt; string 'Smith' (length=1)
    'age' =&gt; string '24' (length=1)
    'birthdate' =&gt; string '19920512' (length=0)
    'joindate' =&gt; string '20160923' (length=0)
    'graduationdate' =&gt; string '' (length=0)
  </code></pre>
  
  <p>I want to convert the date strings to date time object like this;</p>
  
  <pre><code>$record['birthdate'] = \DateTime::createFromFormat('Ymd', $record['birthdate']);
  </code></pre>
  
  <p>But I want to automatically detect the date keys, and make the value a datetime object, if the value is an empty string it can just make it false.</p>
  
  <p>I'm a bit confused</p>
  
  <pre><code>foreach ($record as $value) {
      $value = \DateTime::createFromFormat('Ymd', $value['xxx']);
  }
  </code></pre>