I inherited a database that stores the times as 900 for 9:00am and 1500 for 3:00pm. How can I convert these numbers to normal time formats in PHP?
关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率

已采纳
在PHP中,如何从数字转换为常规时间格式
收起
- 写回答
- 好问题 0 提建议
- 关注问题
微信扫一扫
点击复制链接分享
- 邀请回答
- 编辑 收藏 删除 结题
- 收藏 举报
1条回答 默认 最新
- 关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率
duandao6414 2014-11-22 18:30关注Use the PHP
mktime()
function. So you would do something like this:$hour = substr($time, 0, -2); // Get everything before last two chars of string $minute = substr($time, -2); // Gets last two chars of string $newtime = mktime($hour, $minute);
Then use PHP
date()
to format it how you want.本回答被题主选为最佳回答 , 对您是否有帮助呢? 本回答被专家选为最佳回答 , 对您是否有帮助呢? 本回答被题主和专家选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏举报微信扫一扫
点击复制链接分享
编辑预览轻敲空格完成输入- 显示为
- 卡片
- 标题
- 链接
评论按下Enter换行,Ctrl+Enter发表内容
编辑
预览

轻敲空格完成输入
- 显示为
- 卡片
- 标题
- 链接
报告相同问题?
提交
- 2022-08-23 10:37回答 1 已采纳 <?php # 获取RFC3339格式的时间字符串 $str1 = date(DATE_RFC3339); # 时间字符串转时间戳 echo strtotime($str1); echo "
- 2022-05-23 02:17回答 1 已采纳 $str='0时40分40秒'; $pap = '/^(\d+)时(\d+)分(\d+)秒$/'; preg_match($pap,$str,$m); $miao=$m[1]*3600+$m[2]*6
- 2019-04-04 23:20回答 1 已采纳 You can find functions to do that here
- 2020-12-17 16:38然而,在某些情况下,我们可能需要将这些科学计数法的数字转换为常规的字符串形式,以便于人类阅读或者特定的格式化需求。在PHP中,我们可以自定义函数来实现这一转换。下面我们将详细讨论如何实现这个功能,并解释...
- 2019-06-30 00:51回答 1 已采纳 it should work like this: <script> var player = new Clappr.Player({ source: window.atob
- 2018-11-09 06:35回答 3 已采纳 This is a blanket statement on how to get your desired array : $desired_array = array(array("0"=&
- 2018-09-11 10:12回答 3 已采纳 I couldn't do it with PHPSpreadSheet. In case someone runs with the same problem, this is what I d
- 2015-08-03 02:161. **字符串处理**:在PHP中,可以使用`str_replace()`、`explode()`、`implode()`等函数处理字符串,找到中文数字并替换为阿拉伯数字。 2. **条件逻辑**:通过`if`、`else`或`switch`语句来处理不同结构的中文数字...
- 2015-03-14 02:38回答 2 已采纳 I found it! before converting string to integer, I should convert arabic number to english using t
- 2018-07-31 23:08回答 3 已采纳 As the data your trying to iterate over is an array (from an object) the notation should be... $r
- 2011-12-15 20:08回答 27 已采纳 You don't typically need to do this, since PHP will coerce the type for you in most circumstances.
- 2021-04-08 08:56简单的KeyValue转换器 这是什么? Valve正在使用类似JSON格式的Key...具有相同键的行中的多个元素将被视为常规数组,此键为其名称,所有值均为数组值 这也可以反向执行:如果您有一个常规数组并将其转换为KV,它将是一
- 2020-12-22 09:06weixin_39760619的博客 网上找了一些时间格式的转变,但是都没找到我要的方法先记下我要的转换方法吧,把yyyyMMddHHmmss格式的字符串转换为datetime格式的时间DateTime dt = DateTime.ParseExact("20060709110901","yyyyMMddHHmmss",System...
- 2021-08-03 06:45济南凡事的博客 可以在Excel中验证,首先在一个单元格中输入2021-8-3,然后将单元格格式修改为“常规”,然后就会看到单元格内容变成了44411。 Excel中的时间是一个从0到0.99999999之间的小数值,表示从00:00:00(12:00:00 AM)到...
- 2024-05-10 10:33小胖伦的夕阳粉的博客 【代码】Excel日期数字转化成时间格式。
- 没有解决我的问题, 去提问
联系我们(工作时间:8:30-22:00)
400-660-0108kefu@csdn.net在线客服
- 京ICP备19004658号
- 经营性网站备案信息
公安备案号11010502030143
- 营业执照
- 北京互联网违法和不良信息举报中心
- 家长监护
- 中国互联网举报中心
- 网络110报警服务
- Chrome商店下载
- 账号管理规范
- 版权与免责声明
- 版权申诉
- 出版物许可证
- ©1999-2025北京创新乐知网络技术有限公司