0

I am trying to add 1 minute to the current time:

echo date("Y-m-d H:m:s", strtotime("+60 seconds"));
echo '<br />';
echo date("Y-m-d H:m:s");

The output is in both cases:

2012-09-02 17:09:02
2012-09-02 17:09:02

Which is obviously wrong (in both cases - the current time is in my country 1AM).

What I am doing wrong? I have saved into the datetime column the value 2012-09-02 17:09:38 and now I try to add to the current time 60 seconds and then if the difference between stored datetime and the current datetime is less than 60s, then I want to inset another row in the database...

But the problem is, the date() function displays weird output.

3 Answers 3

7
("Y-m-d H:i:s");

not

("Y-m-d H:m:s"); 

m is month, it can't be minutes as well

Sign up to request clarification or add additional context in comments.

Comments

3

date("m") will show the current month numerically. So this is why your +60 seconds does not work. Use date("Y-m-d H:i:s")

Why the current time is wrong could be several reasons. Probably something with time or timezone settings on your server.

Comments

1

As far as timezone goes, this might help you: date_default_timezone_set

Comments

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.