如何将 EJS 模板的 table 列的字符串转换为 dd-mm-yyyy 格式?
How to convert EJS Template's table column's strings in dd-mm-yyyy Formats?
我正在通过 EJS template
渲染,table data
来自 Database
<td><%= Patient.StudyDate %></td>
Patient.StudyDate
是 string
并呈现为 20181029
(第一个 4
是一年然后 2
是一个月最后一个 2
是一天,所以我想将此 string
更改为 dd-mm-yyyy
),它来自数据库
我想这样展示29-10-2018
如何在 EJS 模板语言中做到这一点?
<td><%= Patient.StudyDate.toString().replace(/^(\d{4})(\d{2})(\d{2})$/, '--')%></td>
使用正则表达式匹配年、月、日并按正确顺序排列
// Patient.StudyDate.replace(/^(\d{4})(\d{2})(\d{2})$/, '--');
console.log('20181029'.replace(/^(\d{4})(\d{2})(\d{2})$/, '--'));
我正在通过 EJS template
渲染,table data
来自 Database
<td><%= Patient.StudyDate %></td>
Patient.StudyDate
是 string
并呈现为 20181029
(第一个 4
是一年然后 2
是一个月最后一个 2
是一天,所以我想将此 string
更改为 dd-mm-yyyy
),它来自数据库
我想这样展示29-10-2018
如何在 EJS 模板语言中做到这一点?
<td><%= Patient.StudyDate.toString().replace(/^(\d{4})(\d{2})(\d{2})$/, '--')%></td>
使用正则表达式匹配年、月、日并按正确顺序排列
// Patient.StudyDate.replace(/^(\d{4})(\d{2})(\d{2})$/, '--');
console.log('20181029'.replace(/^(\d{4})(\d{2})(\d{2})$/, '--'));