Tell me how to display time from the column of the table in the format "hours: minutes". I deduce the data from the table with the code shown below, but the time is displayed in the format hours: minutes: seconds. I understand that you need to format something like this: echo date_format($date, 'Ymd H:i:s');
But it did not work out. Help me please.
This is how information from the table is displayed:
function show_list() { $query = 'SELECT show_id, show_time, show_title, show_author FROM schedule ORDER BY show_time ASC'; $res = mysql_query($query); echo '<h2>Список</h2>'; echo '<table border="1" cellpadding="2" cellspacing="0">'; echo '<tr><th>ID</th><th>Время</th><th>Шоу</th><th>Автор</th><th>Редактировать</th><th>Удалить</th></tr>'; while ($row = mysql_fetch_assoc($res)) { echo '<tr>'; echo '<td>'.$row['show_id'].'</td>'; echo '<td>'.$row['show_time'].'</td>'; echo '<td>'.$row['show_title'].'</td>'; echo '<td>'.$row['show_author'].'</td>'; echo '<td><a href="'.$_SERVER['PHP_SELF'].'?action=editform&id='.$row['show_id'].'">Редактировать</a></td>'; echo '<td><a href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$row['show_id'].'">Удалить</a></td>'; echo '</tr>'; } echo '</table>'; echo '<p><a href="'.$_SERVER['PHP_SELF'].'?action=addform">Добавить</a></p>'; }
SELECT show_id, DATE_FORMAT(show_time, '%H:%i') as show_time, show_title, show_author FROM schedule ORDER BY show_time ASC
- Alexey ShimanskyDATE_FORMAT
be applied toid
?)) And probably not displayed because when using the function the column will be named differently than you expected .... i.e. the column will be called this way (DATE_FORMAT(show_time, '%H:%i')
) ... so you should add an aliasas show_time
- Alexey Shimansky