mktime未返回正确的结果

时间:2015-10-30 18:30:08

标签: php date datetime time

所以我陷入了烦人的事情!这样:

    for($x=59;$x >=0 ;$x--)
        {
            $days_ago1 = date('00,00,00,m,d,Y', time() - $x * SECONDS_PER_DAY);
//debuging  echo "**.".$days_ago1.".**";
            $days_ago1=mktime($days_ago1);
            $days_ago2 = mktime(date('23,59,59,m,d,Y', time() - $x * SECONDS_PER_DAY));
            echo $days_ago1."<br>";
            echo $days_ago2."<br>";
        }

返回: 注意纪元时代不会改变。我已经确认日期会减少,但mktime结果不会。

  

**。00,00,00,09,01,2015。** 1446178911 1446261711

     

**。00,00,00,09,02,2015。** 1446178911 1446261711

     

**。00,00,00,09,03,2015。** 1446178911 1446261711

     

**。00,00,00,09,04,2015。** 1446178911 1446261711

     

**。00,00,00,09,05,2015。** 1446178911 1446261711

     

**。00,00,00,09,06,2015。** 1446178911 1446261711

     

**。00,00,00,09,07,2015。** 1446178911 1446261711

     

**。00,00,00,09,08,2015。** 1446178911 1446261711

我也试过这个:

for($x=59;$x >=0 ;$x--)
    {
        echo date('00,00,00,m,d,Y', strtotime("-$x days"))."<br>";
        //so $date_begin is going to by in      
        $days_ago1 = mktime(date('00,00,00,m,d,Y', strtotime("-$x days")));

        echo $days_ago1."<br>";
        $days_ago2 = date('23,59,59,m,d,Y');
        $days_ago2=(mktime($days_ago2)-($x * SECONDS_PER_DAY));
        echo "Date 1: ".date("Y-m-d\TH:i:s\Z", $days_ago1)."<br>";
        echo "Date 2: ".date("Y-m-d\TH:i:s\Z", $days_ago2)."<br>";
        //get 'x' number of days ago usage rate
        $SQLpid = "SELECT sum(minsused) FROM transactions WHERE subid = '$company' AND  (timestamp AND planid='$planid' AND direction='outbound'";
    }

/*

它仍然会返回:

  <00> 00,00,00,09,04,2015 1446442355日期1:2015-11-02T00:32:35Z日期2:   2015-09-05T00:32:35Z 00,00,00,09,05,2015 1446442355日期1:   2015-11-02T00:32:35Z日期2:2015-09-06T00:32:35Z 00,00,00,09,06,2015   1446442355日期1:2015-11-02T00:32:35Z日期2:2015-09-07T00:32:35Z   00,00,00,09,07,2015 1446442355日期1:2015-11-02T00:32:35Z日期2:   2015-09-08T00:32:35Z 00,00,00,09,08,2015 1446442355日期1:   2015-11-02T00:32:35Z日期2:2015-09-09T00:32:35Z 00,00,00,09,09,2015   1446442355日期1:2015-11-02T00:32:35Z日期2:2015-09-10T00:32:35Z   00,00,00,09,10,2015 1446442355日期1:2015-11-02T00:32:35Z日期2:   2015-09-11T00:32:35Z 00,00,00,019,11,2015 1446442355日期1:   2015-11-02T00:32:35Z日期2:2015-09-12T00:32:35Z 00,00,00,09,12,2015   1446442355日期1:2015-11-02T00:32:35Z日期2:2015-09-13T00:32:35Z

0 个答案:

没有答案