function timediff( $begin_time, $end_time )
{
    if ( $begin_time < $end_time ) {
        $starttime = $begin_time;
        $endtime = $end_time;
    } else {
        $starttime = $end_time;
        $endtime = $begin_time;
    }
    $timediff = $endtime - $starttime;
    $days = intval( $timediff / 86400 );
    $remain = $timediff % 86400;
    $hours = intval( $remain / 3600 );
    $remain = $remain % 3600;
    $mins = intval( $remain / 60 );
    $secs = $remain % 60;
    $res = array( "day" => $days, "hour" => $hours, "min" => $mins, "sec" => $secs );
    return $res;
}

  

;

php自定义函数: 计算两个时间日期相隔的天数,时,分,秒的更多相关文章

  1. php计算时间差/两个时间日期相隔的天数,时,分,秒.

    function timediff( $begin_time, $end_time ) { if ( $begin_time < $end_time ) { $starttime = $begi ...

  2. javascript中计算两个时间日期间隔的天数

    <script>              /*                  计算两个日期的时间间隔天数              */              //时间字符串的格 ...

  3. Java计算两个字符串日期之间的天数差

    Java计算两个字符串日期之间的天数差 调用方法: public static void main(String[] args) throws ParseException { String a = ...

  4. oracle截取时间的年/月/日/时/分/秒

    修改日期格式为年月日时分秒: alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';select to_char(sysdate,'yyy ...

  5. JAVA中计算两个时间相差多少 天,时,分,秒

    1: import java.util.Date; 2: 3: public class ShowTimeInterval{ 4: public void ShowTimeInterval(Date ...

  6. C#WinForm中显示实时时间:年/月/日 时/分/秒 星期X

    //加载窗体时 string weekstr = ""; private void Form22_Load(object sender, EventArgs e) { this.t ...

  7. [Windows]获取当前时间(年/月/日/时/分/秒)

    struct tm* GetCurTime(time_t inTime) { struct tm* curTime = localtime(&inTime); curTime->tm_y ...

  8. oracle计算两个时间的差值(XX天XX时XX分XX秒)

    在工作中需要计算两个时间的差值,结束时间 - 开始时间,又不想在js里写function,也不想在java里去计算,干脆就在数据库做了一个函数来计算两个时间的差值.格式为XX天XX时XX分XX秒: 上 ...

  9. PHP用strtotime()函数比较两个时间的大小实例详解

    在PHP开发中,我们经常会对两个时间的大小进行判断,但是,在PHP中,两个时间是不可以直接进行比较,因为时间是由年.月.日.时.分.秒组成的,所以,如果需要将两个时间进行比较的话,我们首先要做的就是将 ...

随机推荐

  1. 修改MySQL数据库存储位置datadir

    2017-04-14 1.找到mysql安装目录,默认是C:/ProgramData/MySQL/MySQL Server 5.1,找到my.ini.如果这个文件没有,自己建一个my.ini. 2.假 ...

  2. 2017.3.31 spring mvc教程(六)转发、重定向、ajax请求

    学习的博客:http://elf8848.iteye.com/blog/875830/ 我项目中所用的版本:4.2.0.博客的时间比较早,11年的,学习的是Spring3 MVC.不知道版本上有没有变 ...

  3. ElasticSearch高级查询

    ElasticSearch高级查询 https://www.imooc.com/video/15759/0 ElasticSearch查询 1,子条件查询:特定字段查询所指特定值 1.1query c ...

  4. wmi在渗透测试中的运用

    Abusing WMI to Build a Persistent, Asynchronous, and Fileless Backdoor 滥用 WMI 打造一个永久.异步.无文件后门 http:/ ...

  5. List装form

    List<MemberPrivilegeForm> formlist = new ArrayList<MemberPrivilegeForm>(); int status = ...

  6. bzoj2115【WC2001】Xor

    2115: [Wc2011] Xor Time Limit: 10 Sec  Memory Limit: 259 MB Submit: 2059  Solved: 856 [Submit][Statu ...

  7. ”ftp使用dos命令“

    ftp不能使用dos命令,ftp有专用的命令. 在批处理文件中,如果用到dos命令获取信息(比如:系统日期),将用获取的信息,输出到ftp脚本文件中,然后执行ftp脚本文件. set yyyy=%DA ...

  8. RabbitMQ功能测试+性能测试简单方法

    一.如何测试RabbitMQ的功能 1.联系开发找到队列的名称:登录MQ后台管理地址;点击Queues页,输入队列名搜索出目标队列(支持模糊查询) 2.准备测试数据 (1)已知json格式时,根据不同 ...

  9. Android中关于cursor类介绍

    使用过 SQLite 数据库的童鞋对 Cursor 应该不陌生,如果你是搞.net 开发你大可以把Cursor理解成 Ado.net 中的数据集合相当于dataReader.今天特地将它单独拿出来谈, ...

  10. SpringSecurity学习一----------最简单的权限控制系统

    © 版权声明:本文为博主原创文章,转载请注明出处 1.项目结构 2.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0& ...