错误获取日期时间laravel

时间:2017-01-26 20:45:37

标签: php mysql laravel

您好 我从某人那里买了一个项目,当我运行它时,我遇到了问题。 问题是当我尝试从此链接加载与CURL匹配时http://www.planetwin365.com/ControlsSkin/OddsEvent.aspx?ShowLinkFastBet=0&showDate=1&showGQ=1&rnd=049759534356372304&EventID=7944&GroupSep=undefined 到我的数据库我告诉我这个问题 enter image description here

这是我的代码

 private function get_date_time($date,$time){
        if(!Auth::user()->hasRole(['correction', 'admin'])){
            return redirect('/');
        }
        //sabato 4 giugno 2016
        $dates = explode(' ',$date);
        $times = str_replace('.',':',$time);
        switch ($dates[2]){
            case 'gennaio':
                $month = 01;
                break;
            case 'febbraio':
                $month = 02;
                break;
            case 'marzo':
                $month = 03;
                break;
            case 'aprile':
                $month = 04;
                break;
            case 'maggio':
                $month = 05;
                break;
            case 'giugno':
                $month = 06;
                break;
            case 'luglio':
                $month = 07;
                break;
            case 'agosto':
                $month = 8;
                break;
            case 'settembre':
                $month = 9;
                break;
            case 'ottobre':
                $month = 10;
                break;
            case 'novembre':
                $month = 11;
                break;
            case 'dicembre':
                $month = 12;
                break;
            default:
                $month = 01;
        }
        //2016-04-24 05:09:03
        return $dates[3].'-'.$month.'-'.$dates[1].' '.$times;
    }

请帮帮我

1 个答案:

答案 0 :(得分:0)

看起来$dates数组只有三个元素。请记住数组中的第一个索引是0而不是1.我无法确认它,因为此服务在我的国家/地区不起作用,但以下应该可以解决问题。

switch ($dates[1]){

//...

$day = str_replace('.','',$dates[0]);
return $dates[2].'-'.$month.'-'.$day.' '.$times;