Skip to content

Instantly share code, notes, and snippets.

@laozhu
Last active January 2, 2016 09:49
Show Gist options
  • Select an option

  • Save laozhu/8285349 to your computer and use it in GitHub Desktop.

Select an option

Save laozhu/8285349 to your computer and use it in GitHub Desktop.
How to custom datetime filter in Flask
# 第一种定义方式
@app.template_filter('datetimeformat')
def datetimeformat(value, format='%Y/%m/%d %H:%M'):
return value.strftime(format)
# 第二种定义方式
def datetimeformat(value, format='%Y/%m/%d %H:%M'):
return value.strftime(format)
app.jinja_env.filters['datetimeformat'] = datetimeformat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment