{now:format:timestamp}

Description

Returns the current date and time, formatted with a PHP date() pattern. The first argument format is the date() format string (for example Y-m-d H:i:s); leave it empty for the AA default format. The optional second argument timestamp is a Unix timestamp to format instead of the present moment - handy for re-formatting a stored time. Because the value changes every second, now is never cached and its examples are illustrative.

Parameters

format optional default (empty - defaults to U)

A PHP date() format string, such as Y for the year, j.n.Y for day.month.year, or DATE_ATOM for a constant name (any DATE_ constant is resolved). If left empty the format defaults to U, the Unix timestamp.

timestamp optional default (empty - current server time)

The moment to format. May be a Unix timestamp integer, or a textual date such as 2008-07-01 that strtotime can parse. A field-getter (for example a publish date) can be combined with math to compute a relative date. If omitted, the current server time is used.

Examples

virtual{now:Y}
Expected(the current year, for example 2026)
Actual2026
The most common use: with only a format and no timestamp, now prints the current server time. Y is the 4-digit year. Runtime-dependent, so this is illustrative rather than asserted.
virtual{now}
Expected(the current Unix timestamp, for example 1717449200)
Actual1780862620
With no arguments at all, now returns the current time as a Unix timestamp (seconds since 1970). This bare form is what you feed to math and compare. Runtime-dependent, so illustrative.
test{now:Y-m-d:1700000000}
Expected2023-11-14
Actual2023-11-14
Pass a Unix timestamp as the second argument to format that exact moment instead of the current time. Here Y-m-d gives the ISO date.
test{now:j.n.Y:1700000000}
Expected14.11.2023
Actual14.11.2023
The same timestamp in day.month.year - the common Czech and European date layout.
test{now:Y-m-d:2008-07-01}
Expected2008-07-01
Actual2008-07-01
The second argument can be a textual date instead of an integer; strtotime parses it. Useful when the source value is already a yyyy-mm-dd string.
test{now:m/d/Y:{math:1700000000+(24*3600)}}
Expected11/15/2023
Actual11/15/2023
The canonical relative-date pattern: add 86400 seconds (one day) to a base timestamp with math, then format. In real templates the base is usually a field-getter such as the publish date.
test{now::1700000000}
Expected1700000000
Actual1700000000
Leaving the format empty makes now fall back to U, the raw Unix timestamp. With an explicit timestamp this just echoes it back; the same trap applies to the bare current time.
vAA_Stringexpand_Now