python - 《Flask Web开发》 3.6使用Flask-Moment本地化日期和时间
PHP中文网
PHP中文网 2017-04-18 10:11:38
[Python讨论组]
PHP中文网
PHP中文网

认证0级讲师

全部回复(3)
黄舟

我把开发者工具里右边箭头指向的框里的√去掉时间就显示出来了

---------------------------------------------------------------------------------------

我把index.html里面加了点代码,时间能够正常显示了,反正暂时还不知道为什么

index.html代码

{% extends "base.html" %}

{% block page_content %}
<h1>Hello World!</h1>

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

{% endblock %}
PHP中文网

current_time=datetime.utcnow(),大哥,你不是用的是utc时间嘛,我们不是UTC啊。用datetime.now()

黄舟

你好,我也碰到这样的情况,不知道是什么原因。查看页面源码显示:

<p>The local date and time is <span class="flask-moment" data-timestamp="2017-01-01T12:51:42Z" data-format="format('LLL')" data-refresh="0" style="display: none">2017-01-01T12:51:42Z</span>.</p>
<p>That was <span class="flask-moment" data-timestamp="2017-01-01T12:51:42Z" data-format="fromNow(0)" data-refresh="60000" style="display: none">2017-01-01T12:51:42Z</span></p>

可能和“display:none”有关。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号