now

Returns a Carbon instance for the current date and time in the application timezone.

Signature
now($tz = null): CarbonInterface

Parameters

ParameterTypeDescription
$$tzoptionalDateTimeZone|string|int|BackedEnum|null= nullTimezone for the returned instance. When omitted, the timezone from your app's date configuration is used. A backed enum is unwrapped with enum_value().

Return value

CarbonInterfaceAn Illuminate\Support\Carbon instance set to the current moment, in the given timezone or the application timezone.

Errors

Throws Carbon\Exceptions\InvalidTimeZoneException when the timezone string is not a recognised identifier.

Changelog

  • PHP 12.xThe helper is declared as returning CarbonInterface and delegates to Date::now(), so a custom date class registered with Date::use() is honoured.

now() is the shortest way to get the current moment as a date object. It forwards to Date::now(), and the object you get back is Illuminate\Support\Carbon — Carbon's mutable class with a few Laravel conveniences added. Reach for it when stamping a record, comparing against an expiry column, or as the starting point of a date calculation.

The timezone argument

With no argument the instance carries your application's configured timezone, which is UTC in a default install. Pass an identifier such as 'Europe/Madrid' when you need the same instant expressed for a user's locale — the underlying instant is identical, only the wall-clock reading and offset change.

Two calls are two moments

Every call reads the clock again, so now()->eq(now()) is usually false: the two instances differ by microseconds. Capture one instance in a variable when you need several values to agree.

Making it testable

Anything that calls now() is hard to assert on until the clock is fixed. Carbon::setTestNow('2026-03-14 09:41:07') pins it globally; inside a Laravel test the framework wrappers $this->freezeTime(), $this->travelTo() and $this->travel(5)->days() do the same thing and undo themselves. Always release the freeze — Carbon::setTestNow() with no argument — or later assertions in the same process inherit the frozen clock.

Example

Try it yourself
Loading editor…
Press Run to execute the code.

When to use it

  • Stamping an activity record with the moment an action happened.
  • Building a cutoff for a query, such as everything created in the last hour.
  • Freezing the clock in a test so a time-sensitive assertion is reproducible.

Frequently asked questions

What is the difference between now() and Carbon::now()?

now() is a helper that calls Date::now(), which returns Illuminate\Support\Carbon, while Carbon::now() returns Carbon\Carbon directly. Illuminate\Support\Carbon extends Carbon\Carbon, so every Carbon method is available either way; the helper also honours a custom date class registered through Date::use().

How do I freeze the current time for a test?

Call Carbon::setTestNow('2026-03-14 09:41:07') to pin the clock, and Carbon::setTestNow() with no argument to release it. In a Laravel test, $this->freezeTime(), $this->travelTo() and $this->travel(5)->days() wrap the same mechanism and are undone for you at the end of the test.

Why does now() return a different value each time I call it?

Because each call reads the system clock again, so two calls in the same request differ by microseconds and are not equal. Assign the result to a variable and reuse it when several values must refer to the same instant.

More examples

Comparing against a stored timestamp

A 'datetime' cast turns the column into a Carbon instance, so it compares directly with now() — no string parsing and no manual format. Writing now() into an attribute stores it in the connection's format automatically.

Example · php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Subscription extends Model
{
    protected function casts(): array
    {
        return ['ends_at' => 'datetime'];
    }

    public function isActive(): bool
    {
        return $this->ends_at !== null && $this->ends_at->isAfter(now());
    }

    public function markCancelled(): void
    {
        $this->forceFill(['cancelled_at' => now()])->save();
    }
}

Freezing time inside a test

freezeTime() pins the clock for the duration of the closure and restores it afterwards, so now() inside the model returns the same instant the test set up. travel() moves the frozen clock forward without touching the database.

Example · php
<?php

use App\Models\Invoice;
use Illuminate\Support\Carbon;

test('an invoice falls overdue after 30 days', function () {
    $this->freezeTime(function (Carbon $time) {
        $invoice = Invoice::factory()->create([
            'due_at' => now()->addDays(30),
        ]);

        expect($invoice->isOverdue())->toBeFalse();

        $this->travel(31)->days();

        expect($invoice->fresh()->isOverdue())->toBeTrue();
    });
});

The same instant in another timezone

Both instances describe the same instant — equalTo() proves it — but they render with different wall-clock readings and offsets. The timezone argument affects presentation, not the point in time.

Example · php
<?php

use Carbon\Carbon;

Carbon::setTestNow('2026-03-14 09:41:07');

$utc = now();
$madrid = now('Europe/Madrid');

echo $utc->toIso8601String(), "\n";     // 2026-03-14T09:41:07+00:00
echo $madrid->toIso8601String(), "\n";  // 2026-03-14T10:41:07+01:00
var_dump($utc->equalTo($madrid));        // bool(true)

Carbon::setTestNow();

Discussion

  • Be the first to comment on this lesson.