Dates and Times
@Date — date and time (31 methods)
All @Date methods work with Unix timestamps (integer seconds since January 1, 1970 UTC). Use integer arithmetic to add or subtract time.
Current time
ZYMBA
$now = @Date.now(); // Unix timestamp (integer seconds)
$exact = @Date.nowExact(); // Unix timestamp with microseconds (float)
$today = @Date.today(); // Midnight today (start of day)
Formatting
ZYMBA
echo @Date.format("Y-m-d H:i:s"); // "2026-02-08 12:30:00"
echo @Date.format("l, F j, Y", $timestamp); // "Sunday, February 8, 2026"
echo @Date.formatUTC("Y-m-d\\TH:i:s\\Z", $ts); // UTC format
Common format codes:
| Code | Description | Example |
|---|---|---|
Y | 4-digit year | 2026 |
m | Month (01-12) | 02 |
d | Day (01-31) | 08 |
H | Hour 24h (00-23) | 14 |
i | Minutes (00-59) | 30 |
s | Seconds (00-59) | 45 |
l | Day name | Sunday |
F | Month name | February |
j | Day (no padding) | 8 |
U | Unix timestamp | 1770551803 |
Format constants:
| Constant | Pattern |
|---|---|
@Date.FORMAT_ISO8601 | Y-m-d\TH:i:sP |
@Date.FORMAT_ISO9075 | Y-m-d H:i:s |
@Date.FORMAT_RFC2822 | D, d M Y H:i:s O |
@Date.FORMAT_RFC3339 | RFC 3339 format |
Parsing
ZYMBA
$ts = @Date.parse("2026-02-08");
$ts = @Date.parse("2026-02-08 14:30:00");
Creating timestamps
ZYMBA
$ts = @Date.create(15, 6, 2026, 10, 30, 0); // June 15, 2026 at 10:30:00
$utc = @Date.createUTC(15, 6, 2026, 10, 30, 0); // Same but in UTC
Extracting components
ZYMBA
$ts = @Date.now();
echo @Date.getYear($ts); // 2026
echo @Date.getMonth($ts); // 2
echo @Date.getDay($ts); // 8
echo @Date.getHour($ts); // 12
echo @Date.getMinute($ts); // 30
echo @Date.getSecond($ts); // 45
echo @Date.getDayOfWeek($ts); // 0 (Sunday) to 6 (Saturday)
echo @Date.getDayOfWeekISO8601($ts); // 1 (Monday) to 7 (Sunday)
echo @Date.getDayOfYear($ts); // 39
echo @Date.getWeekISO8601($ts); // 6 (ISO week number)
echo @Date.getYearISO8601($ts); // 2026
echo @Date.getDaysInMonth($ts); // 28
Validation and checks
ZYMBA
echo @Date.isValid(29, 2, 2024); // true (leap year)
echo @Date.isValid(29, 2, 2025); // false
echo @Date.isLeapYear($ts); // false (2026)
echo @Date.isMidnight($ts); // false
echo @Date.inDST($ts); // false (February, no DST)
Truncation
ZYMBA
$ts = @Date.now();
echo @Date.format("Y-m-d H:i:s", @Date.truncateDay($ts)); // "2026-02-08 00:00:00"
echo @Date.format("Y-m-d", @Date.truncateMonth($ts)); // "2026-02-01"
echo @Date.format("Y-m-d", @Date.truncateYear($ts)); // "2026-01-01"
Timezone
ZYMBA
echo @Date.getTimezone(); // "Europe/Berlin"
echo @Date.getTimezoneAbbreviation(); // "CET"
echo @Date.getTimezoneOffset(); // 3600 (seconds from UTC)
// Temporarily switch timezone with context manager
with (new @Date.TimezoneContext("UTC")) {
echo @Date.format("H:i:s"); // Time in UTC
}
// Automatically restored to default timezone
// List all available timezones
$zones = @Date.listTimezones();
Date arithmetic
Unix timestamps are integers (seconds), so arithmetic is straightforward:
ZYMBA
$now = @Date.now();
$tomorrow = $now + 86400; // +1 day
$nextWeek = $now + 7 * 86400; // +7 days
$oneHourAgo = $now - 3600; // -1 hour