moments.js, 'type object' has no attribute 'utc' moments.js, 'type object' has no attribute 'utc' flask flask

moments.js, 'type object' has no attribute 'utc'


Try this:

from flask import Flask, render_templatefrom flask_moment import Momentfrom datetime import datetimeapp = Flask(__name__)moment = Moment()moment.init_app(app)@app.route("/")def main_page():    return render_template('main.html', now=datetime.utcnow())if __name__ == "__main__":    app.run(debug=True)

template - main.html

{% block page_content %}{{ moment(now).format('LLL') }}{% endblock %}


The documentation you are referring to is for JavaScript.

The code you are showing is written in Python. Either find the corresponding function in the Python wrapper to do the UTC conversion or call the .utc() function in JS inside of your view template.