Get Current Date Time and Day in Laravel

Posted by

Let’s look at a Laravel example of how to obtain the current date and time. I’d want to demonstrate how to obtain the current date in Laravel. You can learn how to obtain the current time in Laravel with this example. You may discover how to obtain the most recent timestamp in Laravel here. for Laravel to obtain the current date, follow the steps below.

With Laravel 6, Laravel 7, Laravel 8, Laravel 9, and Laravel 10, you can apply this example.

I’ll demonstrate how to obtain the current date, time, timestamp, and day in a Laravel application in this example. To obtain the current carbon object, we will utilize the auxiliary method now(). Let’s examine each example one at a time.

Example 1: Laravel Get Current Timestamps

$timestamp = now();
// Output
2023-07-09T03:48:36.721266Z

Example 2: Laravel Get Current Date

$date = now()->format('Y-m-d');
// OutPut
2023-07-09

Example 3: Laravel Get Current Time

$time = now()->format('H:i:s');
// OutPut
03:48:36

Example 4: Laravel Get Current Day

$time = now()->format('l');
// output 
Friday
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x