1

I am using date function to find current time as date('Y-m-d H:i:s');

I want to find 15 mint from now using PHP using date function

Please help me.

2 Answers 2

3
date('Y-m-d H:i:s',strtotime('+15 minutes'))
Sign up to request clarification or add additional context in comments.

2 Comments

you are right...actually I have a time in database and I want to add 15 mints from that time. Lets say I want to add 15 mints from 2010-12-07 17:54:10. What I have to write then?
date('Y-m-d H:i:s',strtotime('2010-12-07 17:54:10')+60*15)
2

strtotime() is your friend here. It will parse all kinds of input and give you a time using plain English.

echo date('Y-m-d H:i:s', strtotime('+15 minutes'))

2 Comments

you are right...actually I have a time in database and I want to add 15 mints from that time. Lets say I want to add 15 mints from 2010-12-07 17:54:10. What I have to write then?
In this case, you can pass the timestamp as a second paramater to strtotime(): date('Y-m-d H:i:s', strtotime('+15 minutes', $timestamp))... assuming the time is stored in the database as an integer. If it's in the format YYYY-MM-DD HH:mm:ss then use @stillstanding's code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.