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.
("Y-m-d H:i:s");
not
("Y-m-d H:m:s");
m is month, it can't be minutes as well
date("m")
will show the current month numerically. So this is why your +60 seconds does not work. Use date("Ymd H:i:s")
Why the current time is wrong could be several reasons. Probably something with time or timezone settings on your server.
就时区而言,这可能对您有帮助: date_default_timezone_set
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.