title: convert date/time from 24-hour format to 12-hour AM/PM using select query in php/Mysql
body: <p>Displaying Time and date in 12hour format using mysql select query in php. </p>
  
  <p>DB Name <strong>Demo</strong> </p>
  
  <p>Table name <strong>student</strong></p>
  
  <p><strong>DB Structure</strong></p>
  
  <pre><code>Id      firstname    lastname      pubdate
  int(11) varchar(100) varchar(100)  timestamp
  </code></pre>
  
  <p>I have inserted 5 records in student table and displayed using select query everything works great
  but i am unable to display pubdate in proper 12 hour format! </p>
  
  <p>please can somebody help me out in
  acheiving it Thanks!</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>$sql = "select id,firstname,lastname,pubdate from student";
  $results = mysqli_query($con,$sql);
  while($row = mysqli_fetch_array($results))
  {
     echo $row['id'];
     echo $row['firstname'];
     echo $row['lastname'];
     echo $row['pubdate'];
  
  }
  </code></pre>