jinjia2前端模版想要截取整型數據

後端拿到數據庫的數據爲int型

如 20190718

想要在前端轉換成 2019年07月18日 或者 2019-07-18

# flask端代碼
date_local = 20190718
return render_template('test.html', date = date_local)
# test.html 代碼
# 展示 2019年07月18日
 <td>{{ (date | string)[0:4] }}年{{ (date | string)[4:6] }}月{{ (date | string)[6:] }}日</td>
# 展示 2019-07-18
 <td>{{ (date | string)[0:4] }}-{{ (date | string)[4:6] }}-{{ (date | string)[6:] }}</td>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章