当前位置:网站首页>PHP时间戳相减转化为天小时分秒
PHP时间戳相减转化为天小时分秒
2022-07-28 11:24:00 【历史老师-】
两时间戳相减得到相差时间的秒数,然后转化成X天X小时X分X秒
<?php
// 自定义函数:time2string($second) 输入秒数换算成多少天/多少小时/多少分/多少秒的字符串
function time2string($second){
$day = floor($second/(3600*24));
$second = $second%(3600*24); // 除去整天之后剩余的时间
$hour = floor($second/3600);
$second = $second%3600; // 除去整小时之后剩余的时间
$minute = floor($second/60);
$second = $second%60; // 除去整分钟之后剩余的时间
// 返回字符串
return $day.'天'.$hour.'小时'.$minute.'分'.$second.'秒';
}
// 获取从现在到2011年11月11日11点11分11秒还有多久
$time1 = strtotime('2021-11-11 11:11:11');
$time2 = strtotime(now);
// 相减得到相差的 秒 数
$time3 = $time1 - $time2;
// 输出
echo '从现在到2021年11月11日11点11分11秒还有:'.time2string($time3);————————————————
版权声明:本文为CSDN博主「别惹轩轩」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xuander666/article/details/108443935
边栏推荐
- tolua之wrap文件的原理与使用
- Character function and string function (Part 1)
- consul安装与配置
- An idea plug-in helps you transform dto, VO, Bo, Po, do gracefully
- Skiasharp's WPF self drawn drag ball (case version)
- Google Earth engine (GEE) -- problems in the use of coordinate projection and reduceresolution functions in image downscaling
- Reflect 机制获取Class 的属性和方法信息
- 多线程与高并发(三)—— 源码解析 AQS 原理
- 2022.07.07 summer training personal qualifying (II)
- 学会使用MySQL的Explain执行计划,SQL性能调优从此不再困难
猜你喜欢

Stored state and running state of program
![Opencv notes sorting [Hough transform]](/img/80/8f5b0d7e1c5adc39cb5404dcdb1b11.png)
Opencv notes sorting [Hough transform]

Training mode and practice of digital applied talents in Colleges and Universities under the integration of industry and education

配置Jupyter远程服务器

Simple selection sort and heap sort

Hcip (PAP authentication and chap authentication of PPP)

Rest style

Lua对table进行深拷贝

社区点赞业务缓存设计优化探索

游戏流程与底层实现 逐步完成
随机推荐
Laravel之缓存
Anonymous implementation class object of interface
【补题日记】[2022牛客暑期多校2]D-Link with Game Glitch
Use Baidu PaddlePaddle easydl to complete garbage classification
2022.07.10 summer training personal qualifying (V)
一些多参数函数的具体作用
The reflect mechanism obtains the attribute and method information of class
新手如何快速完成建站?来免费“试衣间”体验
Hcip (PAP authentication and chap authentication of PPP)
Opencv notes sorting [Hough transform]
Skiasharp's WPF self drawn drag ball (case version)
本地化、低时延、绿色低碳:阿里云正式启用福州数据中心
Specific process of strong cache and negotiation cache
[diary of supplementary questions] [2022 Niuke summer multi school 2] l-link with level editor I
【补题日记】[2022牛客暑期多校2]L-Link with Level Editor I
Untiy controls the playback speed of animation
tolua之wrap文件的原理与使用
Specific functions of some multi parameter functions
What is WordPress
从0开发一个自己的npm包