rwahdan1978 Posted yesterday at 01:08 PM Share Posted yesterday at 01:08 PM I am trying to get the current time and add 10 minutes before saving to DB. $addingTenMinutes= strtotime('now() + 10 minute'); $end_time = date('Y-m-d H:i:s', $addingFiveMinutes); why it is not working? Quote Link to comment https://forums.phpfreaks.com/topic/327484-how-to-get-the-current-time-and-add-10-minutes/ Share on other sites More sharing options...
Solution Olumide Posted yesterday at 01:18 PM Solution Share Posted yesterday at 01:18 PM 7 minutes ago, rwahdan1978 said: I am trying to get the current time and add 10 minutes before saving to DB. $addingTenMinutes= strtotime('now() + 10 minute'); $end_time = date('Y-m-d H:i:s', $addingFiveMinutes); why it is not working? You're assigning $addingTenMinutes but then using $addingFiveMinutes, which doesn't exist. Also, strtotime('now() + 10 minute') is not a valid syntax for strtotime. Here is a corrected version: $addingTenMinutes = strtotime('+10 minutes'); $end_time = date('Y-m-d H:i:s', $addingTenMinutes); Quote Link to comment https://forums.phpfreaks.com/topic/327484-how-to-get-the-current-time-and-add-10-minutes/#findComment-1653320 Share on other sites More sharing options...
Barand Posted yesterday at 01:30 PM Share Posted yesterday at 01:30 PM If the only reason for that value is to write to the DB then you can do it in the insert query... INSERT INTO tablename (colx, coly, colz) VALUES (?, ?, NOW() + INTERVAL 10 MINUTE) Quote Link to comment https://forums.phpfreaks.com/topic/327484-how-to-get-the-current-time-and-add-10-minutes/#findComment-1653321 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.