Luminova Framework

PHP Luminova: Tasks Date & Time Validations Utility

Last updated: 2026-11-28 20:57:12

Check whether an event has started, expired, or reached its reminder threshold.

Use Task for time-based decisions such as activating a promotion or sending a subscription reminder. Its methods compare a target date with the current time. For date arithmetic and formatting, see Immutable Date and Time Operations.

For an opening window, compare both boundaries explicitly:

use Luminova\Time\Time;

$now = Time::now('UTC');
$opening = $now->setTime(8, 0);
$closing = $now->setTime(17, 0);
$isOpen = $now >= $opening && $now < $closing;

Class Definition

  • Class namespace: Luminova\Time\Task

Methods

expired

Check if a given date and time has passed.

public static function expired(string $datetime, DateTimeZone|string|null $timezone = 'UTC'): bool

Parameters:

ParameterTypeDescription
$datetimestringThe expiration date and time (e.g., '2023-09-25 08:00AM').
$timezoneDateTimeZone&#124;string&#124;nullOptional timezone string.

Return:

bool - Returns true if the task has expired, false otherwise.

Useful for checking if a deal or promo code has expired.


before

Check whether the reminder threshold has been reached. Pair this with expired() when reminders should stop at expiration.

public static function before(string $datetime, int $days = 2, DateTimeZone|string|null $timezone = 'UTC'): bool

Parameters:

ParameterTypeDescription
$datetimestringExpiration date and time in Y-m-d H:iA format.
$daysintNumber of days to check before expiration (default: 2).
$timezoneDateTimeZone&#124;string&#124;nullPass a DateTimeZone instance for explicit timezone handling.

Return:

bool - Returns true at or after the reminder threshold, including after expiration.

Throws:

Example:

use Luminova\Time\Task;
use Luminova\Time\Time;

$zone = new DateTimeZone('UTC');
$expiry = Time::now($zone)->modify('+1 day')->setTime(8, 0)->format('Y-m-d H:iA');

$shouldRemind = Task::before($expiry, 2, $zone)
    && !Task::expired($expiry, $zone);

started

Check if a given datetime has started, or if it should be treated asstarted earlier using a "before" offset.

public static function started(
    string $datetime,
    int $before = 0,
    DateTimeZone|string|null $timezone = 'UTC'
): bool

Parameters:

ParameterTypeDescription
$datetimestringThe target date and time (e.g. "2025-01-10 10:00").
$beforeintSeconds to move the start earlier. Zero and negative values leave the start unchanged (default 0).
$timezoneDateTimeZone&#124;string&#124;nullTimezone to use for both values (default 'UTC').

Return:

bool - Returns true if the event has started, or the early-start threshold has passed.

Example:

use Luminova\Time\Task;
use Luminova\Time\Time;

$startsAt = Time::now('UTC')->modify('+30 minutes')->format('Y-m-d H:i:s');
$canPreview = Task::started($startsAt, before: 3600, timezone: 'UTC');