title: Remove optional time component from datetime stamp string
body: <p>I am processing some strings in a PHP script which may be in <code>Y-m-d H:i:s</code> or <code>Y-m-d</code> format.  I need to remove the <code> H:i:s</code> portion from the datetime strings so that I am consistently dealing with <code>Y-m-d</code> date strings.</p>
  <p>How can I remove this trailing string (and its leading space) <em>if</em> it exists?</p>
  <p>My strings might look like <code>2003-11-24 23:52:18</code> or <code>2009-01-25</code>.</p>
  <p>My expected results from these strings are <code>2003-11-24</code> and <code>2009-01-25</code>.</p>
  <p>I do not need to validate that these strings represent real &quot;date&quot; or &quot;datetime&quot; values.</p>