Laravel Carbon Get Current Timestamp Example

November 25, 2020 | Category : Other

Hi All,In this post, we will learn laravel carbon get current year. let’s discuss about laravel carbon get current day. This article will give you simple example of laravel carbon today date format. i would like to share with you carbon current date time laravel.

Let's see one by one example:

Laravel Carbon Current Date Time:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Carbon\Carbon;

class SignaturePadController extends Controller

{

/**

* Write code on Method

*

* @return response()

*/

public function index()

{

$todayDate = Carbon::now();

dd($todayDate);

}

}

Output:

Carbon\Carbon Object

(

[date] => 2020-11-24 03:54:24.408223

[timezone_type] => 3

[timezone] => UTC

)

Laravel Carbon Current Date:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Carbon\Carbon;

class SignaturePadController extends Controller

{

/**

* Write code on Method

*

* @return response()

*/

public function index()

{

$todayDate = Carbon::now()->format('Y-m-d');

dd($todayDate);

}

}

Output:

2020-11-24

Laravel Carbon Current Time:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Carbon\Carbon;

class SignaturePadController extends Controller

{

/**

* Write code on Method

*

* @return response()

*/

public function index()

{

$todayDate = Carbon::now()->format('H:i:m');

dd($todayDate);

}

}

Output:

04:00:11

Laravel Carbon Current Day/Month/Year:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Carbon\Carbon;

class SignaturePadController extends Controller

{

/**

* Write code on Method

*

* @return response()

*/

public function index()

{

$day = Carbon::now()->format('d');

$month = Carbon::now()->format('m');

$year = Carbon::now()->format('Y');

}

}

Output:

24

11

2020

I hope it can help you...