title: PHP get Datetime per preg_match
body: <p>I want to get the DateTime from a string in the format <code>'YYYY-MM-DD hh:mm:ss</code>.</p>
  
  <p>To clearify: I'm getting a string from an API, by now the string looks like this:</p>
  
  <pre><code>{ts '2014-09-02 14:42:49'}
  </code></pre>
  
  <p>But the string could be changed, so I won't just shorten the string to only the <code>DateTime</code> That's why i want to receive it via a RegEx. Because then the string can change as much as it wants, as long as the Date Format stays the same  I'll always get the right result.</p>
  
  <p>I found this <a href="https://stackoverflow.com/questions/37732/what-is-the-regex-pattern-for-datetime-2008-09-01-123545">question</a> with a solution and tried to use it for my case.
  The RegEx is this:</p>
  
  <pre><code>$regEx = "(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})";
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>$regEx = "(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})";
  </code></pre>
  
  <p>It's working on <a href="http://regexr.com/39ei7" rel="nofollow noreferrer">regexr.com</a>, but I can't get it to work on my <code>PHP</code> code.</p>
  
  <p>The whole code is this:</p>
  
  <pre><code>        $result = array();
          $regEx = "(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})";
          preg_match($details['date'], $regEx, $result);
          var_dump($result);
  </code></pre>
  
  <p>But the <code>var_dump</code> delivers an empty array.</p>
  
  <p>How must i define the RegEx so it's working with <code>preg_match</code>?</p>