zoukankan      html  css  js  c++  java
  • Easyui的DateBox日期格式化

    http://www.cnblogs.com/wintalen/archive/2011/06/10/2077171.html

    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,"/")));}
    });
  • 相关阅读:
    WEB API&API
    event flow
    JS-for的衍生对象
    JS-function
    Object Constructor
    前端发展史
    JavaScript中document.getElementById和document.write
    正则表达式把Paul换成Ringo
    11th blog
    10th week blog
  • 原文地址:https://www.cnblogs.com/zkwarrior/p/4847428.html
Copyright © 2011-2022 走看看