使用easyui框架 設置時間格式


之前做的一個商城項目,后台系統頁面使用Easyui做的,記錄一個當時卡住的地方:

首先通過<table>標記創建數據網格(datagrid)

<table class="easyui-datagrid" id="contentList" data-options="toolbar:contentListToolbar,singleSelect:false,collapsible:true,pagination:true,method:'get',pageSize:20,url:'*******',queryParams:{categoryId:0}">
    <thead>
    <tr>
   <th data-options="field:'id',width:30">ID</th>
   <th data-options="field:'title',width:120">內容標題</th>
   <th data-options="field:'subTitle',width:100">內容子標題</th>
   <th data-options="field:'pic',width:50,align:'center'">圖片</th>
   <th data-options="field:'created',width:130,align:'center'">創建日期</th>
   <th data-options="field:'updated',width:130,align:'center'">更新日期</th>
</tr>
</thead>
</table>

 

接着在js寫一個方法並引用

 

formatDateTime : function(val,row){

var now = new Date(val);
 return now.format("yyyy-MM-dd hh:mm:ss");

}

 

最后在需要更改那一欄添加改方法

<th data-options="field:'created',width:130,align:'center',formatter:E3.formatDateTime">創建日期</th>

<th data-options="field:'updated',width:130,align:'center',formatter:E3.formatDateTime">更新日期</th>

 

效果如下:

End——————————————————————


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM