-2

我正在使用以下脚本当前显示日期和时间。

我不想显示日期,但如果它不工作似乎无法取出它,我如何将时钟更改为 24 小时,因为它目前是 12 小时。

<?php
$hourdiff = 0; // Replace the 0 with your timezone difference (;
$site = date("l, d F Y g:i a",time() + ($hourdiff * 3600));
echo $site;
?>

希望有人可以提供帮助。

谢谢。

4

6 回答 6

1
a   Lowercase Ante meridiem and Post meridiem        am or pm
A   Uppercase Ante meridiem and Post meridiem        AM or PM
B   Swatch Internet time                             000 through 999
g   12-hour format of an hour without leading zeros  1 through 12
G   24-hour format of an hour without leading zeros  0 through 23
h   12-hour format of an hour with leading zeros     01 through 12
H   24-hour format of an hour with leading zeros     00 through 23
i   Minutes with leading zeros                       00 to 59
s   Seconds, with leading zeros                      00 through 59

根据您的代码,它将是

<?php
$hourdiff = 0; // Replace the 0 with your timezone difference (;
$site = date("l, d F Y H:i",time() + ($hourdiff * 3600));
echo $site;
?>

请参考,PHP日期函数

于 2013-09-06T10:18:31.360 回答
0

查看php时间和日期

尝试 'H' 24 小时

于 2012-04-14T21:24:21.463 回答
0

使用 H 或 G 而不是 g 获得 24 小时格式

于 2012-04-14T21:24:34.233 回答
0

不确定你在用($hourdiff * 3600)逻辑做什么,任何乘以 0 的数字都是 0。你应该阅读与date函数相关的文档。

试试这个:

$site = date('H:i a');
echo $site;
于 2012-04-14T21:24:51.143 回答
0

只需要更改日期参数。检查日期手册。

$site = date('H : i: s');
于 2012-04-14T21:25:48.870 回答
0

RTM,也,在未来向我们展示你如何试图删除日期......

g   12-hour format of an hour without leading zeros 1 through 12
G   24-hour format of an hour without leading zeros 0 through 23
h   12-hour format of an hour with leading zeros    01 through 12
H   24-hour format of an hour with leading zeros    00 through 23
i   Minutes with leading zeros  00 to 59
s   Seconds, with leading zeros 00 through 59

$site = date("G:i a",time() + ($hourdiff * 3600));

于 2012-04-14T21:25:51.947 回答