Hello,
how do i add an hour to time with DATE_ADD in DATE_FORMAT? Here is my code :

<?php
session_start(); 
include('includes/main_funcs.php');
$db = db();
$reponse = $db->query('SELECT name, message, DATE_FORMAT(time, \'%H:%i\') AS forTime FROM chat ORDER BY ID DESC LIMIT 0, 10');

while ($donnees = $reponse->fetch())
{
    echo'['.$donnees['forTime'].'] <strong>'.htmlspecialchars($donnees['name']).'</strong> : ' . htmlspecialchars($donnees['message']);
    echo'<br />';
}

$reponse->closeCursor();
?>

thank you

Recommended Answers

This assumes that time is a MySQL DateTime field.

DATE_ADD(`time`, INTERVAL 1 HOUR)
Jump to Post

All 4 Replies

This assumes that time is a MySQL DateTime field.

DATE_ADD(`time`, INTERVAL 1 HOUR)

no its a time field

Worth a try anyway.

thank you it works!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.