Date/Time Fields

This document is for a version of Craft CMS that is no longer supported. Please refer to the latest version →

Date fields give you a date picker, and optionally a time picker as well.

# Settings

datetime-settings.2x

Date/Time fields let you choose whether you want to show the date, the time, or both.

# The Field

Date/Time fields show either a date picker, a time picker, or both, depending on the settings.

datetime-entry.2x

Dates and times are both formatted for the user’s preferred locale. They are displayed in the site’s timezone, however they get stored in UTC like all other dates in Craft.

# Templating

Calling a Date field in your templates will return a DateTime variable set to the selected date, if there was one.

{% if user.birthday %}
  {{ user.name }}’s birthday is: {{ user.birthday | date('M j, Y') }}
{% endif %}