dsdf64562672 2015-09-27 09:26 采纳率: 0%
浏览 40
已采纳

PHP date_create_from_format无法转换为字符串

I converting do date some inputs variables with date_create_from_format, but in line with $diff2 showing me error 'Could not be converted to a string' I don't know why... code looks like

    /*
             array['id'] = el.attr('data-id');
     array['name'] = el.attr('data-name');
     array['place'] = el.attr('data-place');
     array['color'] = el.attr('data-color');
     array['day']   = $(this).attr('data-day');
     array['month'] = $(this).attr('data-month');
     array['year'] = $(this).attr('data-year');
     array['interval'] = el.attr('data-interval');
     array['notification'] = el.attr('data-notification');
     array['hourFrom'] = formatTime(mousingDayH);
     array['hourFrom']  = formatTime(mousingDayM);
     arra['hour'] = formatTime(el.attr('data-hour'));
     array['minutes'] = formatTime(el.attr('data-minutes'));
     array['hourTo'] = formatTime(el.attr('data-hourTo'));
     array['minutesTo'] = formatTime(el.attr('data-minutesTo'));        


        */


function updateDayCalendarEventInTimelineByDrag($array){
        global $db;

        $array->hour = intval($array->hour);
        $array->minutes = intval($array->minutes);
        $array->hourFrom = intval($array->hourFrom);
        $array->minutesFrom = intval($array->minutesFrom);
        $array->hourTo = intval($array->hourTo);
        $array->minutesTo = intval($array->minutesTo);

        ($array->hour <= 9 ? $array->hour = '0'.$array->hour : $array->hour = $array->hour);
        ($array->minutes <= 9 ? $array->minutes = '0'.$array->minutes : $array->minutes = $array->minutes);
        ($array->hourFrom <= 9 ? $array->hourFrom = '0'.$array->hourFrom : $array->hourFrom = $array->hourFrom);
        ($array->minutesFrom <= 9 ? $array->minutesFrom = '0'.$array->minutesFrom : $array->minutesFrom = $array->minutesFrom);
        ($array->hourTo <= 9 ? $array->hourTo = "0".$array->hourTo : $array->hourTo = $array->hourTo);
        ($array->minutesTo <= 9 ? $array->minutesTo = '0'.$array->minutesTo : $array->minutesTo = $array->minutesTo);       
        $diff2 = date_create_from_format("G:i/j.n.Y", $array->hourTo.":".$array->minutesTo."/".$array->day.".".$array->month.".".$array-year);
    echo $diff2;`
}

`
  • 写回答

1条回答 默认 最新

  • douzong2206 2015-09-27 09:40
    关注

    There's a typo in the last line: $array-year should be $array->year.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题
  • ¥15 有没有人能解决下这个问题吗,本人不会编程
  • ¥15 plotBAPC画图出错
  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗