Jump to content

How to get the current time and add 10 minutes?


Go to solution Solved by Olumide,

Recommended Posts

  • Solution
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);

 

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)

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.