Where is the $time coming from? This isn't tested, but try:
Carbon::createFromFormat('d/m/Y H:i', $date . ' ' . $time);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I currently have a booking form that has two fields.
Date and Time.
Date would return something like 14/04/2015 Time would return 10:30
I'd like to turn this into one field in my database called booking_for had have it an instance of carbon.
Here is my current mutator.
public function setBookingForAttribute($date)
{
$this->attributes['booking_for'] = Carbon::createFromTimestamp(strtotime($date . $time . ":00"));
}
How would I get the $time variable? I have tried $this->time and including time in the function parameter's with no luck.
Please or to participate in this conversation.