如何在PHP中将12小时时间转换为24小时制?

栏目: PHP · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/3092558/how-do-i-convert-12-hour-clock-time-into-24-hour-clock-time-in-php

我正在使用以下功能,我想要24小时时钟格式的时间,但这给了我12小时的时间:

<?php
date_default_timezone_set('Asia/Kolkata');
$timestamp =  date("d/m/Y h:i:s", time());
print $timestamp ;
?>

我究竟做错了什么?

docs for date()

:H格式字符以24小时格式给出小时.此外,如果您不希望在中午前几小时领先0,您可以使用G.

示例(如果当前时间是七分之一AM)

date(‘H:i:s’) – > “7点22分13秒”

date(‘G:i:s’) – > “7点22分13秒”

对于您的具体情况:

$timestamp = date("d/m/Y H:i:s", time());

翻译自:https://stackoverflow.com/questions/3092558/how-do-i-convert-12-hour-clock-time-into-24-hour-clock-time-in-php


以上所述就是小编给大家介绍的《如何在PHP中将12小时时间转换为24小时制?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Neural Networks for Applied Sciences and Engineering

Neural Networks for Applied Sciences and Engineering

Samarasinghe, Sandhya / CRC Pr I Llc / 2006-9 / $ 118.59

In response to the exponentially increasing need to analyze vast amounts of data, Neural Networks for Applied Sciences and Engineering: From Fundamentals to Complex Pattern Recognition provides scient......一起来看看 《Neural Networks for Applied Sciences and Engineering》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

随机密码生成器
随机密码生成器

多种字符组合密码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具