python flask web development actual combat flask-moment date

1、
from flask.ext.moment import Moment
moment = Moment(app)
2、
templates/base.html
{% block scripts %}
{{ super() }}
{{ moment.include_moment() }}
{% endblock %}
3、

display time

from datetime import datetime
@app.route('/')
def index():
return render_template('index.html',current_time=datetime.utcnow())
4、

Page display time

<p>The local date and time is {{ moment(current_time).format('LLL') }}.</p>
<p>That was {{ moment(current_time).fromNow(refresh=True) }}</p>

Auto Refresh refresh = True

5
moment.js
format()
formatNow()
fromTime()
calendar()
valueOf()
unix()

Reproduced in: https: //www.jianshu.com/p/2f279ba55757

Guess you like

Origin blog.csdn.net/weixin_34112208/article/details/91071749