开发者

PHP time() changes hours and seconds but not minutes?

开发者 https://www.devze.com 2023-03-17 09:19 出处:网络
I\'m trying to output the current date and time using this code: $theDate = date(\'y-m-d H:m:s\', time());

I'm trying to output the current date and time using this code:

$theDate = date('y-m-d H:m:s', time());
echo $theDate; 

And it works fine but the output for time does not change minutes, it simply sites at HH:07:SS, so the minute sits at 07 and the only thing that changes is the seconds and hours.

Is this because of the time function inside PHP? Does it only update minutes so often? Why would it not update the minutes as well?

How can I get an output the same bu开发者_JAVA百科t with minutes showing correctly?

Whenever i run strftime on the server it outputs fine, just trying to figure it out above.


Use i not m:

$theDate = date('y-m-d H:i:s'); echo $theDate;

07 is July :)


m represents months, not minutes. You need to use i for minutes. See the date() manual page for more information.

$theDate = date('y-m-d H:i:s'); echo $theDate;


Your format string is wrong.

It could be: y-m-d H:i:s


You dont need to give date function the second parameter time().

Just try date("format string");

0

精彩评论

暂无评论...
验证码 换一张
取 消