Tutorials References Exercises Videos Menu
Create Website Get Certified Upgrade

now Template Tag


Example

Add the current date:

<!DOCTYPE html>
<html>
<body>

<h1>{% now "Y-m-d" %}</h1>

</body>
</html>
Run Example »

Definition and Usage

The now tag inserts the current date and/or time, according to the specified format.

Example

Add the current date and time:

<!DOCTYPE html>
<html>
<body>

<h1>{% now "Y-m-d G:i:s" %}</h1>

</body>
</html>
Run Example »

Syntax

{% now format %}

Parameters

Value Description
format Required. A string with any combination of these characters:

Character Description
y Year, 2 digits (00-99)
Y Year, 4 digits (0001-9999)
L Returns whether now is a leap year or not (True-False)
m Month, 2 digits (01-12)
n Month, 1 or 2 digits (1-12)
M Month, 3 letters (Jan-Dec)
b Month, 3 lower case letters (jan-dec)
E Month, text in local language
F Month, full text (January-December)
N Month, max 5 letters, if month name has more, use proper abbreviation (Jan. Dec.)
t Number of days in month (28-31)
d Day of month (01-31)
D Day of week (Sun-Sat)
j Day of month (1-31)
l Day of week (Sunday-Saturday)
S Ending of number (st-nd-rd-th)
w Day of week (0-6)
z Day of year (1-366)
W Week of year (ISO-8601) (1-53)
g Hour (1-12)
G Hour (0-23)
h Hour (01-12)
H Hour (00-23)
i Minutes (00-59)
s Seconds (00-59)
u Microseconds (000000-999999)
a Meridiem (a.m. or p.m.)
A Meridiem (A.M. or P.M.)
f The Time (9:45). If the time is precisely (on the minute) nine, it returns only the hour (9)
P The Time (9:45 p.m.). If the time is precisely (on the minute) nine, it returns (9 p.m.). If the time is precisely 0:00, it returns (midnight). If the time is precisely 12:00 it returns (noon).
e Name of time zone, like (GMT) or (UTC)
I Returns whether we are in daylight saving time or not (1 or 0)
O The difference to GMT (+0500)
T Local time zone, like (UTC) or (EST)
Z Difference to GMT, in seconds (3600)
c Current date in ISO 8601 format (2022-04-05T12:38:30.797643+00:00)
r Current date in RFC 5322 format (Tue, 05 Apr 2022 12:39:24 +0000)
U Seconds since January 1 1970 00:00:00