MYSQL TIMESTAMP when adding DATE_FORMAT then the output is blank, PHP conflict?


Usingthe following shortcode function, I have the code building a table by querying the DB. That all works fine. BUT when I add any type of formatting to the TimeStamp column such as DATE_FORMAT or TIME the output for that column only goes blank. No errors are in the console to look at. I am trying to extract only the time and put it in a 12 hour format instead of the typical TIMESTAMP format of date and time in the 24hr set up.

Is there a conflict with some of the PHP that causes it not to display the timestamp?

 function test2() {
        global $wpdb;
    $results = $wpdb->get_results("SELECT `name`, `partysize`, `phonenumber`, `emailaddress`, DATE_FORMAT(`Time_stamp`, '%h %i' ), `Wait`, `currentstatus` FROM mytablename m RIGHT JOIN (SELECT wdt_ID, CONCAT(ROUND(Time_to_sec(TIMEDIFF (NOW() ,`Time_stamp`))/60,0), ' Min') AS Wait FROM mytablename) as t on m.wdt_ID = t.wdt_ID WHERE Time_stamp >= date_sub(now(),interval 3 hour)  "); 
            echo "<table width='100%' border='0' style='display:inline-table'>
            <th>Party Size</th>
            <th>Phone Number</th>
            <th>Email Address</th>
            <th>Time Stamp</th>
            <th>Action</th>     ";
            echo "<tbody>";      
            foreach($results as $row){ 
                echo "<tr>";
                //echo "<td>" . $row->wdt_ID . "</td>";
                echo "<td>" . $row->name . "</td>";
                echo "<td>" . $row->partysize . "</td>";
                echo "<td>" . $row->phonenumber . "</td>";
                echo "<td>" . $row->emailaddress . "</td>";
                echo "<td>" . $row->Time_stamp . "</td>";
                echo "<td id='tdid_".$row->wdt_ID."'>" . $row->currentstatus . "</td>";
                echo "<td>" . $row->Wait . "</td>";
                echo '<td> <a href="javascript:void(0)" class="button seated-btn" onclick="seatclick('.$row->wdt_ID.')" data-id="'.$row->wdt_ID.'"></a></td>';
                echo "</tr>";
            echo "</tbody>";
            echo "</table>"; 
    add_shortcode('test2', 'test2');
Michael 4 months 0 Answers 16 views 0

Leave an answer