ItSolutionStuff.com

How to Get Current Date Time and Day in Laravel?

By Hardik Savani • April 16, 2024
Laravel

Hello Developer,

Now, let's see an example of how to get current date and time in laravel. I would like to show you how to get current date in laravel. This example will help you how to get current time in laravel. Here you will learn how to get current timestamp in laravel. follow the below step for laravel get current date.

You can use this example with laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11.

In this example, i will show you how to get current date, time, timestamp and day in laravel application. we will use now() helper function to get current carbon object. so, let's see the example one by one.

Example 1: Laravel Get Current Timestamps

Code:

$timestamp = now();

Output:

2023-05-19T03:48:36.721266Z

Example 2: Laravel Get Current Date

Code:

$date = now()->format('Y-m-d');

Output:

2023-05-19

Example 3: Laravel Get Current Time

Code:

$time = now()->format('H:i:s');

Output:

03:48:36

Example 4: Laravel Get Current Day

Code:

$time = now()->format('l');

Output:

Friday

I hope it can help you...

Tags: Laravel
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Laravel Carbon Count Days Between Two Dates Example

Read Now →

Laravel Carbon Parse Date Format Example

Read Now →

How to Check Date is Today's Date or not in Laravel Carbon?

Read Now →

Laravel Carbon Time Format AM PM Example Code

Read Now →

How to use Carbon in Laravel Blade or Controller File?

Read Now →

Laravel Carbon diffForHumans() Example

Read Now →

Carbon Get First Day of Specific Month Example

Read Now →

Laravel Carbon Get Last Day of Month Example

Read Now →

Laravel Carbon Check If Date is Greater Than Other Date

Read Now →

Laravel Carbon Check Current Time Between Two Date Time Example

Read Now →

Laravel Carbon Subtract Hours Example

Read Now →

Laravel Carbon Subtract Year Example

Read Now →

Laravel Carbon addYears() | Laravel Carbon Add Year Example

Read Now →

Laravel Carbon Subtract Months from Date Example

Read Now →

Laravel Carbon Add Days to Date Example

Read Now →