title: How to convert string with date and time AM/PM to 24 Hour mysql timestamp format
body: <p>I am trying to insert date and time into mysql datetime field from a string having following <strong>dd/mm/yyyy hh:mm:ss AM/PM</strong> format:</p>
  
  <pre><code>20/10/2014 05:39 PM
  
  20/10/2014 05:39 AM
  </code></pre>
  
  <p>I know MYSQL timestamp format is yyyy-mm-dd hh:mm:ss  or <strong>0000-00-00:00:00:00</strong></p>
  
  <p>So if I do: </p>
  
  <pre><code>$s = substr("20/10/2014 05:39 PM", 0, 10);
  $h = date("G:i", strtotime($s));
  list($day, $month, $year, $hour, $minute) = split('[/ :]', "20/10/2014 05:39 PM"); 
  echo $d1me = $year . '-' . $month. '-' .  $day . ' ' . $h;
  </code></pre>
  
  <p>I get <code>2014-10-20 19:00</code></p>
  
  <p>So I guess there is  a problem with date_default_timezone_set() function, How to solve this and get expected result?</p>
  
  <pre><code>20/10/2014 05:39 PM     -&gt;   2014-10-20 17:39:00
  
  20/10/2014 05:39 AM     -&gt;   2014-10-20 05:39:00
  </code></pre>
  
  <p>How to do it?</p>