简体   繁体   English

PHP time() 改变小时和秒但不改变分钟?

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

I'm trying to output the current date and time using this code:我正在尝试使用此代码 output 当前日期和时间:

$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.它工作正常,但时间的 output 不会改变分钟,它只是位于 HH:07:SS,所以分钟位于 07,唯一改变的是秒和小时。

Is this because of the time function inside PHP?这是因为 PHP 内部的时间 function 吗? Does it only update minutes so often?它只更新分钟这么频繁吗? Why would it not update the minutes as well?为什么它也不会更新会议记录?

How can I get an output the same but with minutes showing correctly?如何获得相同的 output 但分钟显示正确?

Whenever i run strftime on the server it outputs fine, just trying to figure it out above.每当我在服务器上运行 strftime 时,它的输出都很好,只是想在上面弄清楚。

Use i not m :使用i而不是m

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

07 is July:) 07 是七月:)

m represents months, not minutes. m代表月,而不是分钟。 You need to use i for minutes.您需要使用i几分钟。 See the date() manual page for more information.有关详细信息,请参阅date()手册页

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

Your format string is wrong.您的格式字符串错误。

It could be: ymd H:i:s可能是: ymd H:i:s

You dont need to give date function the second parameter time().您不需要给日期 function 第二个参数时间()。

Just try date("format string");试试 date("format string");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM