1,105,578 Community Members

Add an hour to a time MySQL

Member Avatar
Sanchixx
Junior Poster in Training
83 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
blocblue
Practically a Posting Shark
828 posts since Jan 2008
Reputation Points: 238 [?]
Q&As Helped to Solve: 162 [?]
Skill Endorsements: 16 [?]
Featured
 
0
 

This assumes that time is a MySQL DateTime field.

DATE_ADD(`time`, INTERVAL 1 HOUR)
Member Avatar
Sanchixx
Junior Poster in Training
83 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

no its a time field

Member Avatar
blocblue
Practically a Posting Shark
828 posts since Jan 2008
Reputation Points: 238 [?]
Q&As Helped to Solve: 162 [?]
Skill Endorsements: 16 [?]
Featured
 
0
 

Worth a try anyway.

Member Avatar
Sanchixx
Junior Poster in Training
83 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

thank you it works!

Question Answered as of 1 Year Ago by blocblue
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article