atstockland Posted October 24, 2008 Share Posted October 24, 2008 Hi all - Im have data stored in a mysql DB using the data type of TIME. I dont want dateTime as I dont care about the date....just time. I want to simply subtract 15 minutes from that time. So, if the time in the database reads 13:00:00 I want to subtract 15 minutes from that so it reads 12:45 PM. I have tried using: $tourTime = $row_Recordset1['TheTimeInMyDatabase']; $tourTime_seconds = strtotime ($tourTime); $meetingTime_seconds = $tourTime_seconds - 900; $adjustedTime = time ("h:i p", $meetingTime_seconds); This seems like a really easy thing to do. Im glad its a struggle for me because its teaching me more about php.....but now Im ready for it to work. Thanks Adam Quote Link to comment https://forums.phpfreaks.com/topic/129892-subtract-15-minutes-from-mysql-time/ Share on other sites More sharing options...
sasa Posted October 24, 2008 Share Posted October 24, 2008 look http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_subtime Quote Link to comment https://forums.phpfreaks.com/topic/129892-subtract-15-minutes-from-mysql-time/#findComment-673460 Share on other sites More sharing options...
atstockland Posted October 24, 2008 Author Share Posted October 24, 2008 Ill give that a try. Id rather do it with php....than in the mysql query. Is there a reason to do it one way or the other? thanks for the reply Quote Link to comment https://forums.phpfreaks.com/topic/129892-subtract-15-minutes-from-mysql-time/#findComment-673844 Share on other sites More sharing options...
discomatt Posted October 24, 2008 Share Posted October 24, 2008 Doing it in the MySQL query is much faster. SELECT DATE_SUB( `dateCol`, INTERVAL 15 MINUTE ) as `dateLess15` Quote Link to comment https://forums.phpfreaks.com/topic/129892-subtract-15-minutes-from-mysql-time/#findComment-673846 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.