How can I get the same timestamp from MomentJS to Carbon instance (GMT timezone)?
$(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());
});
I am getting the correct selected value in the console which says GMT+2.
If I assign the 2 hour less value, it still get's parsed wrong.
Here is Laravel controller:
public function reserveTo($time, $timeTo)
{
Reservation::create([
'reserved_from' => Carbon::createFromTimestamp($time),
'reserved_to' => Carbon::createFromTimestamp($timeTo),
]);
return redirect()->back();
}
via Norgul