NealeWeb Posted April 6, 2011 Share Posted April 6, 2011 I have a guestbook and i want to record and display the time of each post but at the moment all the times are added to the database including seconds so it looks like this - 05:42:33, i just want the hours and minutes like this - 05:42. This is the code that adds the time. $time = date("HH:MM"); $db = mysql_connect($dbHost,$dbUser,$dbPass); mysql_select_db($dbname,$db); $sql="INSERT INTO guestbook (`time`) VALUES ( And this is the code that displays it <?php $db = mysql_connect($dbHost,$dbUser,$dbPass); mysql_select_db($dbname,$db); $requete = " time FROM guestbook ORDER BY ID desc LIMIT 1"; $result = mysql_query ($requete,$db); while($row = mysql_fetch_assoc($result)) { $time = $row["time"]; echo '<span class="font2">'.''.$time.''.'</span>'; } ?> Can anybody help me. Quote Link to comment https://forums.phpfreaks.com/topic/232859-hhmmss-to-hhmm/ Share on other sites More sharing options...
cyberRobot Posted April 6, 2011 Share Posted April 6, 2011 When getting the time from the database, you could look into utilizing the HOUR() and MINUTE() functions. Or maybe the MAKETIME() function would work, but I'm not if you can leave off the seconds argument. For more information on the functions, visit http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Quote Link to comment https://forums.phpfreaks.com/topic/232859-hhmmss-to-hhmm/#findComment-1197693 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.