我在我的控制器中使用它来填充datetime-local输入字段:
public function create()
{
$task = new Task();
$task->start_date = Carbon::now();
$task->due_date = Carbon::now();
return view('tasks.create', compact('task'));
}
这在我看来:
{!! Form::input('datetime-local', 'start_date', $task->start_date->format('Y-m-d\TH:m'), ['class' => 'form-control']) !!}
{!! Form::input('datetime-local', 'due_date', $task->due_date->format('Y-m-d\TH:m'), ['class' => 'form-control']) !!}
但是,字段的值始终为:
<input class="form-control" name="start_date" type="datetime-local" value="2016-05-12T22:05" id="start_date">
如果我在dd($task)
方法中执行create()
,则属性会显示当前时间。
#attributes: array:2 [▼
"start_date" => Carbon {#186 ▼
+"date": "2016-05-12 22:20:14.000000"
+"timezone_type": 3
+"timezone": "UTC"
}
"due_date" => Carbon {#187 ▼
+"date": "2016-05-12 22:20:14.000000"
+"timezone_type": 3
+"timezone": "UTC"
}
]
尝试弄清楚当属性具有正确的时间值时输入显示错误时间的原因。
答案 0 :(得分:0)
您的格式为:
(Year to 4 digits)-(Month with Leading zeros)-(Day to 2 digits with leading zeros)T(Hours in 24 hour format):(Month with Leading zeros)
这意味着:
Y-m-d\TH:i // 'i' = minutes with leading zeros
你想要:
set.seed(12345)
x<-rnorm(1000,0,10)
hist(x)
curve(dnorm(x,0, 10), add=TRUE, yaxt="n", col="red", log=FALSE)