python|python flask web开发实战 flask-moment时间日期

1、
from flask.ext.moment import Moment
moment = Moment(app)
2、
templates/base.html
{% block scripts %}
{{ super() }}
{{ moment.include_moment() }}
{% endblock %}
3、
显示时间 【python|python flask web开发实战 flask-moment时间日期】from datetime import datetime
@app.route('/')
def index():
return render_template('index.html',current_time=datetime.utcnow())
4、
页面中显示时间 The local date and time is {{ moment(current_time).format('LLL') }}.

That was {{ moment(current_time).fromNow(refresh=True) }}

refresh=True自动刷新 5
moment.js
format()
formatNow()
fromTime()
calendar()
valueOf()
unix()

    推荐阅读