0
如何从MomentJS获得相同的时间戳到Carbon实例(GMT时区)?Moment JS to Carbon conversion
$(document).on('click', '#confirm-reservation .dropdown-menu a', function() {
$('#insert_text').text($(this).text());
var href = $(e.relatedTarget).data('href');
var time = moment().year(startTime.format("Y")).month(startTime.format("M")).date(startTime.format("D"))
.hour($(this).text().split(':')[0]).minutes($(this).text().split(':')[1]).seconds("0");
console.log(time);
$('.btn-ok').attr('href', href + '/' + time.unix());
});
我得到正确的选择值,在控制台上说GMT + 2。
如果我指定2小时内的值,它仍然被解析错误。
这里是Laravel控制器:
public function reserveTo($time, $timeTo)
{
Reservation::create([
'reserved_from' => Carbon::createFromTimestamp($time),
'reserved_to' => Carbon::createFromTimestamp($timeTo),
]);
return redirect()->back();
}
我可以看到单个参数传递,如何将两个参数传递给'reserveTo'方法? –
第一个参数始终通过路线(href),如果选择了其他时间,则将其添加到现有路线中。所以我有'/ time/timeTo'通过 – Norgul