Lightweight helpers for date operations, plus the global now() / today() shortcuts.
use Zero\Lib\Support\DateTime;Implementation: DateTime.php, legacy Date.php.
Built on DateTimeImmutable — every mutation returns a new instance.
$now = DateTime::now();
$jakarta = DateTime::now(new DateTimeZone('Asia/Jakarta'));Parses any string supported by PHP's DateTimeImmutable — relative ("yesterday", "next monday") or absolute ("2026-04-25 12:00").
$cutoff = DateTime::parse('2026-04-25');
$tomorrow = DateTime::parse('tomorrow');
$paris = DateTime::parse('today 12:00', new DateTimeZone('Europe/Paris'));$deadline = DateTime::now()->addDays(3);$weekAgo = DateTime::now()->subDays(7);Human-readable difference, e.g. "2 hours ago", "5 days from now".
echo DateTime::now()->addDays(3)->diffForHumans(DateTime::now()); // "3 days from now"Return a clone converted to another timezone.
$utc = DateTime::now()->inTimeZone('UTC');DateTime extends DateTimeImmutable, so PHP's standard methods (format, getTimestamp, etc.) all work:
DateTime::now()->format('Y-m-d H:i:s');
DateTime::now()->getTimestamp();Kept for backwards compatibility. New code should prefer DateTime. The framework also exposes Zero\Lib\Date as an alias of this class.
$now = Date::now();$date = Date::parse('next friday');$next = Date::now()->addDays(7);Note the legacy spelling — subtractDays, not subDays.
$before = Date::now()->subtractDays(7);Date::now()->format('Y-m-d'); // '2026-04-25'
Date::now()->format(); // ATOM, e.g. '2026-04-25T12:34:56+07:00'Drop down to the native PHP \DateTime instance.
$native = Date::now()->toDateTime();$past = Date::parse('yesterday');
echo Date::now()->diffForHumans($past); // "1 day from now"$jakarta = Date::now()->setTimeZone('Asia/Jakarta');Defined in Support/Helper.php.
$now = now(); // Date instance
$tomorrow = now()->addDays(1);Date instance for the start of today.
$today = today();See helpers.md for the full list of global helpers.