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()
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...
Do you like below Tutorials ?
- Multidimensional Array Search By Value in PHP
- Laravel Install Font Awesome Icons Example
- How to Use Moment JS in Laravel?
- Angular 9 Get Environment Variables Example
- Angular Delete a Component From Cli Example
- How to Upload File from Local to Server using SSH?
- Angular Use CKEditor Example Tutorial
- How to Use Multiple Select Dropdown in Laravel?