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

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

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744645431a4585590.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信