Get time from MySQL database

-Good Night, guys!

I have an application that takes data from the database and presents it on the screen. It is a television time grid, that is, it shows what is going on live and what will go on afterwards.

The data type representing the schedule time is DateTime

I would like to take only the hour and minute, ignoring the date. Example: in the bank is like this (2019-08-31 20:50) I want to take only the 20: 50 and show on the screen. I'm doing with php.

How can I do this?

My current Code:

<?php
//SELECT
$gh_resultado = $wpdb->get_results("SELECT * FROM Programacao where horario >= '$gh_data' order by horario");

//Mostrando na tela
echo $gh_resultado[0]->horario;
?>
Author: Vitor Cordeiro, 2019-09-01

1 answers

As already explained only use mysql time () function Example.:

SELECT *, TIME(horario) AS horario FROM Programacao where horario >= '$gh_data' order by horario

Remembering that the name of the property to be returned has changed to TIME (property), then it is important that you rename it again to its old name as

TIME(horario) AS horario
 0
Author: João Carlos Junior, 2019-09-01 03:01:14