1、
from flask.ext.moment import Moment
moment = Moment(app)
2、
templates/base.html
{% block scripts %}
{{ super() }}
{{ moment.include_moment() }}
{% endblock %}
3、
显示时间
from datetime import datetime
@app.route('/')
def index():
return render_template('index.html',current_time=datetime.utcnow())
4、
页面中显示时间
<p>The local date and time is {{ moment(current_time).format('LLL') }}.</p>
<p>That was {{ moment(current_time).fromNow(refresh=True) }}</p>
refresh=True自动刷新
5
moment.js
format()
formatNow()
fromTime()
calendar()
valueOf()
unix()
转载于:https://www.jianshu.com/p/2f279ba55757