How to get the current timestamp in Laravel

Laravel utilizes the Carbon package. It is an API extension for DateTime in PHP. The current time can be fetched with Carbon by using the now() method. This will equal the current time in YYY-mm-dd HH:mm:ss format

use Carbon\Carbon;

...

$now = Carbon::now();

This will get the current timestamp.

$now = Carbon::now()->timestamp;

The Full Stack Dev Newsletter

The Freelance Avatar

Hey, I'm Wes. Every month I send a newsletter with articles on:

  • ​🔥 Hot Web Dev tips
  • 🎨 Web Design
  • 🔨 Product Development

As seen at the top of Hacker News, Indie Hackers, and Hacker Noon.