title: How to make a normal user input of time and date to get it added in mysql as timestamp?
body: <p>In the user interface, i have a text field to enter date in dd/mm/yyyy format and there is another textbox for time in hh:mm format and another dropdown box to specify am or pm. All these three fields will let the user to enter the date,time and am/pm manually. I prefered to use this primitive method as per the requirement of the project.</p>
  
  <p>Now i want all these values to be added in mysql in timestamp format to make it easier to fetch and manipulate. Please suggest me how can i achieve this.</p>
  
  <pre><code>&lt;?
  $date = '21'.'/'.'11'.'/'.'2011';
  $time = '12'.':'.'00';
  $ampm = "am";
  $dt = DateTime::createFromFormat(
      'd/m/Y h:i a',
   sprintf('%s %s %s', $date, $time, $ampm),
     new DateTimeZone('Country/Region'));
  
  
  
  $mysqlDateString = $dt-&gt;format('Y-m-d H:i:s');
  
  
  ?&gt;
  </code></pre>