Easyui的DateBox日期格式化
生活随笔
收集整理的這篇文章主要介紹了
Easyui的DateBox日期格式化
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
DateBox 日期顯示默認的格式為“dd/mm/yyyy”,如果想自定義成我們的格式需要實現兩個函數,formatter和parser。
formatter函數使得選擇日期后將其格式化為我們需要的格式,parser函數在選擇好日期后告訴控件如何去解析我們自定義的格式。
定義如下:
formatter:A function to format the date, the function take a 'date' parameter and return a string value.
parser:A function to parse a date string, the function take a 'date' string and return a date value.
如將日期格式化為yyyy-mm-dd的格式:
$('#dd1').datebox({
??? formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();},
??? parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/")));}
});
formatter函數使得選擇日期后將其格式化為我們需要的格式,parser函數在選擇好日期后告訴控件如何去解析我們自定義的格式。
定義如下:
formatter:A function to format the date, the function take a 'date' parameter and return a string value.
parser:A function to parse a date string, the function take a 'date' string and return a date value.
如將日期格式化為yyyy-mm-dd的格式:
$('#dd1').datebox({
??? formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();},
??? parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/")));}
});
轉載于:https://www.cnblogs.com/wintalen/archive/2011/06/10/2077171.html
總結
以上是生活随笔為你收集整理的Easyui的DateBox日期格式化的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Curl参数一览
- 下一篇: jQuery EasyUI API 中文