Something like this?
$start = Carbon::createFromFormat('d-m-Y g:i A', $date. ' '. $time. ' PM');
$end = $start->copy()->addSeconds($seconds);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I need to convert these strings into a start_date and end_date I get the duration in minutes, date, and time.
Example:
$duration = 60;
$date = 08/13/2020;
$time = 2:00; // PM
I can
return Carbon::createFromFormat('d-m-Y', $date);
I need the final output:
$start_date and $end_date format: YYYY-MM-DD HH:MI:SS with the difference between the two using the duration.
Thanks
Something like this?
$start = Carbon::createFromFormat('d-m-Y g:i A', $date. ' '. $time. ' PM');
$end = $start->copy()->addSeconds($seconds);
Please or to participate in this conversation.