当前位置:网站首页>PHP timestamp subtraction converts to days, hours, minutes and seconds
PHP timestamp subtraction converts to days, hours, minutes and seconds
2022-07-28 12:15:00 【History teacher-】
Subtract the two timestamps to get the seconds of the time difference , And then convert it into X God X Hours X branch X second
<?php
// Custom function :time2string($second) Enter the number of seconds converted into days / How many hours / How many points / How many seconds of string
function time2string($second){
$day = floor($second/(3600*24));
$second = $second%(3600*24); // Except for the rest of the day
$hour = floor($second/3600);
$second = $second%3600; // Except for the rest of the hour
$minute = floor($second/60);
$second = $second%60; // Take out the rest of the whole minute
// Return string
return $day.' God '.$hour.' Hours '.$minute.' branch '.$second.' second ';
}
// Get from now to 2011 year 11 month 11 Japan 11 spot 11 branch 11 How long is the second
$time1 = strtotime('2021-11-11 11:11:11');
$time2 = strtotime(now);
// Subtract to get the difference second Count
$time3 = $time1 - $time2;
// Output
echo ' From now until 2021 year 11 month 11 Japan 11 spot 11 branch 11 Seconds and :'.time2string($time3);————————————————
Copyright notice : This paper is about CSDN Blogger 「 Don't mess with Xuanxuan 」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/xuander666/article/details/108443935
边栏推荐
- Gecko competition 2.0 is new! Come and show your flexible operation skills!
- Docker runs MySQL service
- Direct insert sort and Hill sort
- php⽉份加减最简单的处理⽅法
- Distributed system (III) construction of distributed transaction service
- Develop your own NPM package from 0
- Style conversion model style_ Transformer project instance pytorch implementation
- "Weilai Cup" 2022 Niuke summer multi school training camp 2
- Anonymous implementation class object of interface
- 2022.07.12 summer training personal qualifying (VII)
猜你喜欢

安徽京准:北斗卫星同步时钟|北斗同步时钟|NTP网络时钟服务器

IDEA复制模块

Full resolution of the use of go native plug-ins

简单选择排序与堆排序

顶级“Redis笔记”,缓存雪崩+击穿+穿透+集群+分布式锁,NB了

STL の 概念及其应用

China business CDP white paper | love Analysis Report

Matlab sets the size of graphics window and image and the position of legend

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

Lua对table进行深拷贝
随机推荐
SQL注入 Less18(头部注入+报错注入)
新手如何快速完成建站?来免费“试衣间”体验
【vulnhub】presidential1
ViewPager2+Fragment
Know the optical fiber interface and supporting optical fiber cable of can optical fiber converter in fire alarm networking
How to make the characters in the photos laugh? HMS core video editing service one click smile function makes people smile more naturally
DNS series (III): how to avoid DNS spoofing
Distributed system (III) construction of distributed transaction service
游戏流程与底层实现 逐步完成
Laravel之缓存
Rest style
WebView details
[diary of supplementary questions] [2022 Hangdian summer school 2] k-dos card
Globalthis is not defined solution
“蔚来杯“2022牛客暑期多校训练营2
15、用户web层服务(三)
Interfaces and abstract classes
A new mode of one-stop fixed asset management
Launcher sample code
Anonymous implementation class object of interface