title: Function to parse psql timestamp
body: <p>I display the date or the time on my website a lot and I'm thinking about writing a function to parse a PostgreSQL timestamp.</p>
  
  <p>The timestamp is in the format: <code>Y-m-d H:i:s.u</code>. E.g. <code>2011-04-08 23:00:56.544</code>.</p>
  
  <p>I'm thinking about something like this:</p>
  
  <pre><code>function parse_timestamp($timestamp, $format = 'd-m-Y')
  {
      // parse the timestamp
  
      return $formatted_timestamp;
  }
  </code></pre>
  
  <p>However I am wondering whether this can also be achieved without writing a parser for it myself (with the use of some PHP function).</p>