Phpmysql date calculation code [datediff]-PHP source code

Source: Internet
Author: User
Ec (2); well, the code below is a bit messy. I did it during the test. The phpmysql date computing code [datediff] is also what I will try today. the Code functiona ($ d) {$ Date_1date (& quot; Y-m-d & quot;); & nbsp; $ Date_2 $ d; $ Date_List_a1explode (& quot; -& quot;, $ Date_1); & nbsp; script ec (2); script

The following code is a bit messy: I did it during the test. The php mysql date calculation code [datediff] is also what I will try today. Let's take a look at the code below.

Function a ($ d ){
$ Date_1 = date ("Y-m-d ");

$ Date_2 = $ d;

$ Date_List_a1 = explode ("-", $ Date_1 );

$ Date_List_a2 = explode ("-", $ Date_2 );

$ D1 = mktime (0, 0, 0, $ Date_List_a1 [1], $ Date_List_a1 [2], $ Date_List_a1 [0]);

$ D2 = mktime (0, 0, 0, $ Date_List_a2 [1], $ Date_List_a2 [2], $ Date_List_a2 [0]);

Return round ($ d1-$ d2)/3600/24 );
}

// Echo $ Days;

$ D = date ("Y-m-d H: I: s ");
$ SQL = "Select * from wk_member where m_ip = '2017. 0.0.1 'and datediff (m_dtime,' $ D') = 0 ";
$ Result = mysql_query ($ SQL) or die (mysql_error ());
If (mysql_num_rows ($ result) <5 ){
Echo 'T ';
}
While ($ rs = mysql_fetch_array ($ result )){
Echo $ rs ['id'];
Echo'
';
}

For original site reprinted, please indicate www.111cn.net

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.