当前位置:网站首页>PHP gets the number of days, hours, minutes and seconds between the two timestamps
PHP gets the number of days, hours, minutes and seconds between the two timestamps
2022-07-02 17:53:00 【Famine~】
public function time_cha()
{
$s_date ="2015-12-12 16:00:00";
$e_date ="2016-12-13 18:00:00";
$cha = strtotime($e_date)-strtotime($s_date);
// year
$year = floor((strtotime($e_date)-strtotime($s_date)) / (31536000));
echo "1、 The difference is years :".$year." year <br/><br/>";
// month
$month = floor(($cha - $year * 31536000) / (2592000));
$month_total = floor($cha / 2592000);
echo "2、 Months difference :".$month." month <br/><br/>";// Except last year
echo "3、 Months difference :".$month_total." month <br/><br/>";// Total months
// Japan
$day_total = floor((strtotime($e_date)-strtotime($s_date))/86400);
echo "4、 The total difference is :".$day_total." God <br/><br/>";
// when
$hour = floor((strtotime($e_date)-strtotime($s_date))%86400/3600);
$hour_total = floor((strtotime($e_date)-strtotime($s_date)));// Total phase difference N Hours
echo "5、 Hours difference :".$hour." Hours <br/><br/>";
echo "6、 Total hours difference :".$hour_total." Hours <br/><br/>";
// branch
$minute = floor((strtotime($e_date)-strtotime($s_date))%86400/60);
$minute_total = floor((strtotime($e_date)-strtotime($s_date))/60);
echo "7、 Minutes difference :".$minute." minute <br/><br/>";
echo "8、 Total minutes difference :".$minute_total." minute <br/><br/>";
// second
$second = floor((strtotime($e_date)-strtotime($s_date))%86400%60);
$second_total = floor((strtotime($e_date)-strtotime($s_date)));
echo "9、 Seconds difference :".$second." second <br/><br/>";
echo "10、 Total seconds difference :".$second_total." second <br/><br/>";
}
边栏推荐
- Pfc232-sop8/14/16 should be wide-ranging and can be tape programmed with burning program
- aloam 代码阅读与总结
- Use of nexttile function in MATLAB
- 能解决 80% 故障的排查思路
- 2 juillet: BitTorrent est sorti; L'acquisition du système commercial linspire; Sony Deployment PlayStation now
- 【网络是怎么连接的】第四章 探索接入网和网络运营商
- SAP commerce cloud storefront framework selection: accelerator or Spartacus?
- 基数排序的简单理解
- 每日一题——小乐乐改数字
- 智能水电表能耗监测云平台
猜你喜欢
能解决 80% 故障的排查思路
ORA-19838 -- 恢复控制文件到备库
应广单片机开发 工规 PMC131 带AD芯片检测电池电压单片机SOP8/14
Daily question - inverted string
【网络是怎么连接的】第四章 探索接入网和网络运营商
外包干了五年,废了...
Virtual lab basic experiment tutorial -7 Polarization (2)
Edgenext hit a mixed punch: a lightweight architecture integrating CNN and transformer
每日一题——“水仙花数”
MB10M-ASEMI整流桥MB10M
随机推荐
Use of nexttile function in MATLAB
Larvel document reading notes custom authentication login and registration using larvel 8
原厂原装 应广单片机PMS134方案开发应用案例
Solution to the problem that the easycvr kernel of intelligent video analysis platform cannot be started as a service
【历史上的今天】7 月 2 日:BitTorrent 问世;商业系统 Linspire 被收购;索尼部署 PlayStation Now
透过华为军团看科技之变(六):智慧公路
Daily question - xiaolele changes the number
Taiwan Feiling fm8pb513b MCU provides MCU program development product design
What is the experience of maintaining Wanxing open source vector database
Alibaba Tianchi SQL learning notes - Day3
应广单片机开发案例
Virtual lab basic experiment tutorial -7 Polarization (1)
应广单片机开发 工规 PMC131 带AD芯片检测电池电压单片机SOP8/14
The price is only 40 yuan. Pico development board of raspberry pie is added with WiFi module, and it is out of stock as soon as it comes into the market
应广单片机开发调试应注意的问题
Experience Alibaba cloud character recognition OCR
Platform management background and merchant menu resource management: merchant role management design
辉芒微IO单片机FT60F11F-MRB
每日一题——小乐乐改数字
Ssm+ wechat applet to realize property management system