xxxxxxxxxx
$diff = Carbon::parse( $start_date )->diffInDays( $end_date );
xxxxxxxxxx
$created = new Carbon($survey->created_at);
$now = Carbon::now();
$difference = ($created->diff($now)->days < 1)
? 'today'
: $created->diffForHumans($now);
xxxxxxxxxx
$startdate->diffInDays($todate); //total days between two dates
$startdate->diffInMinutes($todate); //total number of minutes between two dates
$startdate->diffInMonths($todate); //total number of months difference
xxxxxxxxxx
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Carbon\Carbon;
class DateController extends Controller
{
public function index()
{
$currentDateTime = Carbon::now();
$newDateTime = Carbon::now()->addDay();
print_r($currentDateTime);
print_r($newDateTime);
}
}
xxxxxxxxxx
<?php
$d1 = date_create(date('Y').'-'.date('m').'-01'); //current month/year
$d2 = date_create($d1->format('Y-m-t')); //get last date of the month
$days = date_diff($d1,$d2);
echo "Number of days: ". $days->days+1; //+1 for the first day