trpplayer79 Posted September 2, 2007 Share Posted September 2, 2007 Dear, I have a mysql database. in this db I have a time stored from a meeting. when I get the time out of the db and display it it is HH:MM:SS but I only want HH:MM I've searched for a sollution but can't find it. can somebody please give me a sollution for this problem maybe I have to store only the HH:MM in the DB but I didn't find anything about how I can do this. greetz Trpplayer Quote Link to comment https://forums.phpfreaks.com/topic/67661-solved-display-time-from-sql-db/ Share on other sites More sharing options...
wildteen88 Posted September 2, 2007 Share Posted September 2, 2007 If you only want the hour and minutes displayed you can just drop of the seconds part like so: $time = '12:45:00'; list($hours, $minutes, $seconds) = explode(':', $time); echo $hours . ':' . $minutes; // 12:45 Quote Link to comment https://forums.phpfreaks.com/topic/67661-solved-display-time-from-sql-db/#findComment-339866 Share on other sites More sharing options...
trq Posted September 2, 2007 Share Posted September 2, 2007 Or, format the time in your query. SELECT DATE_FORMAT(fld,"%h:%i") AS formattedtime FROM tbl; Quote Link to comment https://forums.phpfreaks.com/topic/67661-solved-display-time-from-sql-db/#findComment-339867 Share on other sites More sharing options...
trpplayer79 Posted September 3, 2007 Author Share Posted September 3, 2007 but how do I integraet this is my current sql string? my current sql string is this: SELECT * FROM [table][tr][td] WHERE datum >= CURDATE( ) AND iedereen = 1 ORDER BY datum'; the hour field is "starthour". Quote Link to comment https://forums.phpfreaks.com/topic/67661-solved-display-time-from-sql-db/#findComment-340661 Share on other sites More sharing options...
wildteen88 Posted September 3, 2007 Share Posted September 3, 2007 Whats the filed that contains the time? You place Thorpes snippet in the SELECT statment, eg: SELECT *, DATE_FORMAT(fld,"%h:%i") AS formattedtime FROM WHERE datum >= CURDATE( ) AND iedereen = 1 ORDER BY datum'; change the highlighted text in red to the column which contains the time. Then use $row['formattedtime'] to get the formatted time Quote Link to comment https://forums.phpfreaks.com/topic/67661-solved-display-time-from-sql-db/#findComment-340712 Share on other sites More sharing options...
trpplayer79 Posted September 3, 2007 Author Share Posted September 3, 2007 THANK YOU for you help. it workes. Quote Link to comment https://forums.phpfreaks.com/topic/67661-solved-display-time-from-sql-db/#findComment-340754 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.