Time difference problem

Source: Internet
Author: User
$a =2014-09-30 23:21:55
$b =18:00

How can I figure out how many minutes the difference between 23:21 and $b is in $ A?


Reply to discussion (solution)

I got it!!!

$d = new DateTime (Date (' H:i:s ', Strtotime (' 2014-09-30 23:21:55 ')), $t = $d->diff (new datetime (' 18:00:0 ')); Echo $t- >format ('%h:%i:%s  '), echo $t->h * + $t->i + $t->s/60;
05:21:55 321.91666666667

$seconds = (Strtotime ("2014-09-30 23:21:55")-strtotime ("18:00") +86400)%86400; $minutes = Floor ($seconds/60); var_dump ($minutes);

Reference function: Strtotime

Or Baidu ' Calculate time difference '

If:
The value of Kq.kq_time is 2014-09-30 23:21:55
The value of kq_c.am_on is 18:00

How to make the following MySQL statement set up?
$sql _where. = "and Date_format (Kq.kq_time, '%h:%i ') >kq_c.am_on";

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.