http://space.flash8.net/space/?559871/action_viewspace_itemid_359366.html

解决方案 »

  1.   

    Date.prototype.toCHString=function(){
     function getCH(Index){
       return "零壹贰叁肆伍陆柒捌玖拾".charAt(Index);
     }
     function getCHStr(str,d){
       var s="";
       if(d=="年")for(var i=0;i<str.length;i++)s+=getCH(parseInt(str.substr(i,1)));
       else{
         var iV=parseInt(str);
         if(iV%10==0)s+=(str.substr(0,1)=="1"?"":getCH(str.substr(0,1)))+getCH(10);
         else if(iV<10)s+=getCH(str.substr(0,1));
         else s+=(str.substr(0,1)=="1"?"":getCH(str.substr(0,1)))+getCH(10)+getCH(str.substr(1,1));
       }
       s+=d;
       return s;
     }
     //二OO八年十月十三日 十五时十二分零三秒
     var result=getCHStr(this.getFullYear().toString(),"年")
               +getCHStr((this.getMonth()+1).toString(),"月")
               +getCHStr(this.getDate().toString(),"日")+"\t"
               +getCHStr(this.getHours().toString(),"时")
               +getCHStr(this.getMinutes().toString(),"分")
               +getCHStr(this.getSeconds().toString(),"秒");
     return result;
    }
    var d=new Date();
    alert(d.toCHString())