title: First and Last Datetime for year or year/month
body: <p>I have an action which accepts a year and an optional month.  I need to query all articles written within that time, so I need the absolute first and last valid datetime for that timespan.  </p>
  
  <pre><code>    $start = new \DateTime();
      $start-&gt;setDate((int) $year, (int) ($month ?: 1), 1);
      $start-&gt;setTime(0, 0);
  
      $end = clone $start;
      $end-&gt;add(new \DateInterval($month ? 'P1M' : 'P1Y'));
      $end-&gt;sub(new \DateInterval('PT1S'));
  </code></pre>
  
  <p>Is there a cleaner way to write this?</p>