添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
唠叨的烈酒  ·  Date日期 | Avue·  24 分钟前    · 
体贴的甘蔗  ·  PostgreSQL 教程: date ...·  48 分钟前    · 
时尚的企鹅  ·  date Filter | Django ...·  2 小时前    · 
面冷心慈的西装  ·  使用PHPs ...·  昨天    · 
失眠的玉米  ·  Download Django | Django·  1 年前    · 
含蓄的人字拖  ·  Android 上排名前 5 ...·  1 年前    · 

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