我的MYSQL数据库中表中有一个DATE字段,有2条DATE记录,分别是2010-03-30 15:22:10 和 2010-03-30 15:24:34我想用  2010-03-30 15:24:34 减去 2010-03-30 15:22:10 
然后得到的值,将它格式化,最终显示为:   00:02:24高手们,帮帮忙!

解决方案 »

  1.   

    echo $a=strtotime("2010-03-30 18:24:34")-strtotime("2010-03-30 15:22:10 ")."<br>";
      

  2.   


    mysql> select timediff('2010-03-30 15:24:34','2010-03-30 15:22:10');
    +-------------------------------------------------------+
    | timediff('2010-03-30 15:24:34','2010-03-30 15:22:10') |
    +-------------------------------------------------------+
    | 00:02:24                                              |
    +-------------------------------------------------------+
    1 row in set (0.00 sec)
      

  3.   

    $a=strtotime("2010-03-30 15:24:34")-strtotime("2010-03-30 15:22:10 ")."<br>";
    $b=strtotime("2010-03-30")+$a;
    echo date("H:i:s",$b);
      

  4.   

    echo $a=date('H:i:s',strtotime("2010-03-30 15:24:34")-strtotime("2010-03-30 15:22:10 "))."<br>";
      

  5.   

    echo date("H:i:s",strtotime("2010-03-30 15:24:34")-strtotime("2010-03-30 15:22:10"))."<br>";
      

  6.   

    $a = strtotime("2010-03-30 18:24:34")-strtotime("2010-03-30 15:22:10 ");
    $a = date("h:i:s",$a);
    echo $a;
      

  7.   

    ysql> select timediff('2010-03-30 15:24:34','2010-03-30 15:22:10');
    +-------------------------------------------------------+
    | timediff('2010-03-30 15:24:34','2010-03-30 15:22:10') |
    +-------------------------------------------------------+
    | 00:02:24                                              |
    +-------------------------------------------------------+
    1 row in set (0.00 sec)
    这个不错哦