dougou3871 2014-08-29 12:06
浏览 30

php中的两个时间值之间的差异[重复]

This question already has an answer here:

I have two time values as follows

$start = '13:00:00';
$end = '21:00:00';

I want calculate the difference between these two time values, I want difference value in format like 00:00:00 (here result would be 08:00:00)

I am using below code to calculate difference

$time = date( "h:i:s", strtotime($end) - strtotime($start));

but it gives me result as 01:30:00

please help if anyone have any idea, i do not want to use DateTime class

In my opinion it is not duplicate, if it is tell me the answer if your can find in duplicate question

</div>
  • 写回答

3条回答 默认 最新

  • dqsxsmi3704 2014-08-29 12:10
    关注

    Try with this code :

    $time1 = strtotime('13:00:00');
    $time2 = strtotime('21:00:00');
    $diff = $time2 - $time1;
    echo 'Difference: '.date('H:i:s', $diff);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起