How To Get Current Date In Laravel

May 20, 2023 | Category : Other

Hello Developer,Hello Dev,
In this short guide, we will show you how to get current date and time in laravel. This article goes in detailed on how to get current date in laravel. you'll learn how to get current time in laravel. I explained simply about how to get current timestamp in laravel. Alright, let’s dive into the steps.

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

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...