xxxxxxxxxx
$period = Carbon::parse(date("Y-m-d H:i:s"))->diff(Carbon::parse($oldSend->valid_until))->format('%I:%S');
xxxxxxxxxx
$today = Carbon::createFromFormat('d/m/Y H:i:s', '19/02/2019 00:00:00');
$day = $today->subDays(1)->format('d/m/Y');
xxxxxxxxxx
use Carbon\Carbon;
$date = Carbon::now();
// Format the date using Carbon
$formattedDate = $date->format('Y-m-d H:i:s');
// Output the formatted date
echo $formattedDate;
xxxxxxxxxx
use Illuminate\Support\Carbon;
$datetime = "yourDateTime"; // example: "2022.12.13" or "2022-12-13T10:00:00.000Z" or etc.
$carbon = Carbon::parse($datetime); // returned new Carbon class by given any formatted date(time)
xxxxxxxxxx
public function scopeDateStart($q, $date) {
return $q->where('date_start', '>=', Carbon::parse($date)->startOfDay());
}
public function scopeDateEnd($q, $date) {
return $q->where('date_end', '<=', Carbon::parse($date)->endOfDay());
}