Formatting of dates and times in Flask templates using moment.js
This extension enhances Jinja2 templates with formatting of dates and times using moment.js.
Quick Start
Step 1: Initialize the extension:
from flask_moment import Moment
moment = Moment(app)
Step 2: In your section of your base template add the following code:
{{ moment.include_jquery() }}
{{ moment.include_moment() }}
This extension also supports the Flask application factory pattern by allowing you to create a Moment object and then separately initialize it for an app:
moment = Moment()
def create_app(config):
app = Flask(__name__)
app.config.from_object(config)
# initialize moment on the app within create_app()
moment.init_app(app)
app = create_app(prod_config)
Note that jQuery is required. If you are already including it on your own