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 ?
- How to Open URL in New Tab using Jquery?
- Laravel 7.x and 6.x Routing Tutorial
- Ng Bootstrap Modal in Angular 8 Example
- Bootstrap 4 Datepicker in Angular 9/8 Example
- Disable Registration Route in Laravel
- Bootstrap Timepicker in Angular Example
- Count Number of Pages in PDF - PHP Script
- Digital Signature PHP Script Example