添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Used to format the date and time of a datetime or date object.

The format argument can be constructed using format strings or one of the following predefined formats:

  • DATE_FORMAT
  • DATETIME_FORMAT
  • SHORT_DATE_FORMAT
  • SHORT_DATETIME_FORMAT
  • Variable

    moon_landing = datetime.datetime(year=1969, month=7, day=21, hour=2, minute=56, second=15, tzinfo=datetime.timezone.utc)

    Sample Formats

  • {{ moon_landing }} – July 21, 1969, 2:56 a.m.
  • {{ moon_landing|date }} – July 21, 1969
  • {{ moon_landing|date:'l, F j, Y' }} – Monday, July 21, 1969
  • {{ moon_landing|date:"DATE_FORMAT" }} – July 21, 1969
  • {{ moon_landing|date:"DATETIME_FORMAT" }} – July 21, 1969, 2:56 a.m.
  • {{ moon_landing|date:"SHORT_DATE_FORMAT" }} – 07/21/1969
  • {{ moon_landing|date:"SHORT_DATETIME_FORMAT" }} – 07/21/1969 2:56 a.m.
  • Note that the predefined formats are based on the current locale.

    Did we get something wrong? Is there a use case for the date filter that we should add? Please let us know.

    Send Feedback