var DateFormat=function(date){
//implementation
var format=function(str){
str=str.replace(/yyyy/g,date.getFullYear());
str=str.replace(/yy/g,date.getFullYear().toString().slice(2));
str=str.replace(/mm/g,date.getMonth()+1);
str=str.replace(/dd/g,date.getDate());
str=str.replace(/wk/g,date.getDay());
str=str.replace(/hh/g,date.getHours());
str=str.replace(/mi/g,date.getMinutes());
str=str.replace(/ss/g,date.getSeconds());
str=str.replace(/ms/g,date.getMilliseconds());
return str;}
var valueOf=function(){}
var toString=function(){
return date.toLocaleString();}
//constructor
date=new Date(date);
if(!date||date=="NaN")
date=new Date();
//inteface
this.format=format;
this.valueOf=valueOf;
this.toString=toString;}
使用:
xxx.value=new DateFormat().format('yy/dd/mm wk')