我正在使用以下脚本来显示日期和时间。
我不想显示日期,但如果没有它不工作似乎无法取出它,我怎样才能将时钟更改为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;
?>
希望有人可以提供帮助。
感谢。
答案 0 :(得分: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;
?>
答案 1 :(得分:0)
尝试'H'24小时
答案 2 :(得分:0)
使用H或G代替g来获得24小时格式
答案 3 :(得分:0)
不确定您使用($hourdiff * 3600)
逻辑做了什么,任何数字乘以0都是0.您应该阅读与date函数相关的文档。
请改为尝试:
$site = date('H:i a');
echo $site;
答案 4 :(得分:0)
只需要更改日期参数即可。查看date手册。
$site = date('H : i: s');
答案 5 :(得分: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:我是”,时间()+($ hourdiff * 3600));