Aug 24, 2020
0
Level 10
How to pass date from Buefy to Laravel?
I am using the Buefy datepicker to let users pick a date at the front end (https://buefy.org/documentation/datepicker).
When I submit the form through axios, the date is a string of this form:
"Mon Aug 03 2020 00:00:00 GMT+0200 (Central European Summer Time)".
In order to save this in a timestamp mysql column, I need to remove the content in the brackets and use the following code to parse it to a string like this: "2020/08/03"
$cleanDate = preg_replace('/\(.*\)/', '', $request->start);
$timestamp = strtotime($cleanDate);
$start = date('Y/m/d', $timestamp);
Is this how you do it, if oyu use a Vue datepicker? It feels so clumsy to me.
Please or to participate in this conversation.