如何将 JSON/Bootstrap-Table 中的日期转换为 DD/MM/YYYY

How do you convert dates in JSON/Bootstrap-Table to DD/MM/YYYY

我想将 2016-09-14T13:46:39+0000 格式化为 DD/MM/YYYY。数据来自 JSON file/url 到 bootstrap-table。有没有办法使用 bootstrap-table 或 javascript 来格式化它?

jsfiddle

谢谢,

<table data-toggle="table" 
   data-url="https://api.myjson.com/bins/44564"
   data-row-style="rowStyle">
<thead>
<tr>
    <th data-field="createdAt">Created At</th>
</tr>
</thead>

检查这将解决您的问题。我正在使用 moment js 来格式化数据。 ..

function dateFormat(value, row, index) {
   return moment(value).format('DD/MM/YYYY');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://momentjs.com/downloads/moment.min.js"></script>
<script src="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.js"></script>
<link href="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.css" rel="stylesheet"/>

<table data-toggle="table" 
       data-url="https://api.myjson.com/bins/44564"
       data-row-style="rowStyle">
    <thead>
    <tr>
        <th data-field="createdAt" data-formatter="dateFormat">Created At</th>
    </tr>
    </thead>
</table>