Skip to main content

Current Date and Time as Smart Field

Insert the current date and time, in any date format you want, in your templates.

Updated over a year ago

There is a smart field to insert the date and time now in your company's timezone:

{{ datetime_now }}

You can change it to any format you want by doing:

{{ datetime_now|date:"Y-m-d H:i:s" }}

This would print:

2024-05-13 15:38:26

If you want to print it in different timezones, have a look here.

The options are:

Category

Format String

Description

Example

Hours

g

Hour, 12-hour format without leading zeros

'1' to '12'

G

Hour, 24-hour format without leading zeros

'0' to '23'

h

Hour, 12-hour format

'01' to '12'

H

Hour, 24-hour format

'00' to '23'

Minutes

i

Minutes

'00' to '59'

Seconds

s

Seconds, 2 digits with leading zeros

'00' to '59'

Period

a

'a.m.' or 'p.m.'

'a.m.', 'p.m.'

A

'AM' or 'PM'

'AM', 'PM'

Days

d

Day of the month, 2 digits with leading zeros

'01' to '31'

j

Day of the month without leading zeros

'1' to '31'

D

Day of the week, textual, 3 letters

'Fri'

l

Day of the week, textual, long

'Friday'

N

ISO-8601 numeric representation of the day of the week

'1' (Monday) to '7' (Sunday)

w

Day of the week, numeric

'0' (Sunday) to '6' (Saturday)

z

Day of the year, starting from '0'

'0' to '365'

Months

m

Month; 2 digits with leading zeros

'01' to '12'

n

Month without leading zeros

'1' to '12'

M

Month, textual, 3 letters

'Jan'

b

Month, textual, 3 letters, lowercase

'jan'

F

Month, textual, long

'January'

Years

y

Year, 2 digits

'99', '23'

Y

Year, 4 digits

'1999', '2023'

L

Boolean for whether it is a leap year

'1' if it is, '0' otherwise

Weeks

W

ISO-8601 week number of year, weeks starting on Monday

'42'

Time Zones

O

Difference to Greenwich time (GMT) in hours

'+0200'

P

Difference to Greenwich time (GMT) with colon

'+02:00'

T

Time zone of this machine

'EST', 'MDT'

Z

Time zone offset in seconds

'-43200' to '50400'

Various

f

Time, in 12-hour hours and minutes, with minutes left off if they're zero

'1', '1:30'

P

Time, in 12-hour hours and minutes, with 'a.m.'/'p.m.'

'1 a.m.', '1:30 p.m.'

S

English ordinal suffix for the day of the month, 2 characters

'st', 'nd', 'rd', 'th'

t

Number of days in the given month

'28' to '31'

Did this answer your question?