最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

datetime - Convert Unix timestamp returned from API in Python Flask app - Stack Overflow

programmeradmin2浏览0评论

I have got a Python Flask app that will get data from API and pass it to html template.

On html template I have following and I would like to convert the "insertionTime" from Unix timestamp to human readable format.

<div class="results">
    
    {% if results %}
        <h2>Results:</h2>
        <ul>
            {% for result in results %}
                <li><strong>{{ result['id'] }}</strong><br>{{ result['insertionTime'] }}<br>{{ result['eventType'] }}<br>{{ result['activity'] }}</li>
                <hr>                    
            {% endfor %}
        </ul>
    {% else %}
        <p>No results found.</p>
    {% endif %}
</div>

I have added flask_moment and changed to the following but it throws AttributeError: 'int' object has no attribute '_render'

<br>{{ moment.unix(result['insertionTime']).format(LLL) }}<br>

Any help would be much appreciated, thank you.

发布评论

评论列表(0)

  1. 暂无评论