How to get Current Timestamp from Carbon in Laravel 5
You can use the now()
method from the Carbon
class to get the current timestamp in Laravel. This method returns an instance of the Carbon
class representing the current date and time. Here's an example of how you can use it:
use Carbon\Carbon;
$timestamp = Carbon::now();
Watch a video course
Learn object oriented PHP
You can also pass a timezone as an argument to the now()
method to get the current timestamp in that timezone. For example:
$timestamp = Carbon::now('Asia/Kolkata');
Note that you need to import the Carbon
class at the top of your file using the use
statement.