input datetime-local 设置默认值

<div class="form-group">
  <label for="start_time" class="col-xs-4 col-sm-2 control-label"><span style="color:red;">span>起始时间 :label>
  <div class="col-xs-8 col-sm-9 form-inline">
    <input type="datetime-local" name="start_time" class="form-control" value="{{old('start_time',$data->start_time)}}">
    <b style="margin-left: 30px;">结束时间 :b>
    <input type="datetime-local" name="end_time" class="form-control" value="{{old('end_time',$data->end_time)}}">
    <span class="help-block m-b-none"><i class="fa fa-info-circle">i>秒置为 00,因此不显示秒数.span>
  div>
div>
$data = TeacherRestSchedule::find($id);
$data->start_time = timeToW3c($data->start_time);


function timeToW3c($datetime, $timezone = 'UTC')
{
    $timestamp = strtotime($datetime);
    if (!$timestamp) {
        return null;
    }
    $date = Carbon::createFromTimeStamp($timestamp, 'UTC');
    $date->setTimezone($timezone);
    $w3c = str_replace(' ', 'T', $date->format('Y-m-d H:i:00'));
    return $w3c;
}

能够识别的格式: 2018-12-02T12:30

效果图

input datetime-local 设置默认值_第1张图片

你可能感兴趣的:(laravel,框架,php)