有三个自定义函数,你自己看着用吧
//Date对象转换成日期字符串
//date 为Date object
//sep  为一个字符,作为分隔符
//返回值是一个形如yyyy-m-d的字符串
function convertDate2String(date,sep)
{
var sa,sb,sc;
if(sep!='-' && sep!='/' && sep!='.' && sep!='@') sep='-';
if(sep=='@')
{
sa='年';
sb='月';
sc='日';
}
else
{
sa=sb=sep;
sc='';
}
return ""+date.getFullYear()+sa+(date.getMonth()+1)+sb+date.getDate()+sc;
}
//Date对象的时间部分转换成时间字符串
//date 为Date object
//type 为格式选择
// 0:默认选择(不省略前缀0,不显示毫秒数,24小时制,符号单位)
//  1:时间前缀0省略
//  2:毫秒显示
// 4:12小时显示(后缀PM、AM)
//  8:中文单位
//返回值是一个形如hh:mm:ss.fff的字符串
function convertTime2String(date,type)
{
var h,m,s,f,pm,r;
var zero,fff,h24,cn;
var sa,sb,sc,sd,se;

zero=true;
fff=false;
h24=true;
if (isEmpty(type)) type=0;
if(typeof(type)=='string') type=type.toInt();
if (type>15||type <0) type=0;
zero=(type %2==0);
type=Math.floor(type/2);
fff=(type%2==1);
type=Math.floor(type/2);
h24=(type%2==0);
type=Math.floor(type/2);
cn=(type%2==1); h = date.getHours();
m = date.getMinutes();
s = date.getSeconds();
f = date.getMilliseconds();
pm=0;

if(cn)
{
sa='时';
sb='分';
sc='秒';
sd='';
se='毫秒';
}
else
{
sa=sb=':';
sc=se='';
sd='.';
}
if (!h24)
{
pm=Math.floor(h/12);
h%=12;
if(pm==1 && h==0) h=12;
}
h=''+h; m=''+m; s=''+s; f=''+f;
if (zero)
{
while (h.length<2) h='0'+h;
while (m.length<2) m='0'+m;
while (s.length<2) s='0'+s;
while (f.length<3) f='0'+f;
}

r=h+sa+m+sb+s+sc;
if (fff)
r+=sd+f+se;
if(!h24)
r+=(pm==0)?' AM':' PM';
return r;
}function Date2Str(date)
{
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
if (hour < 10)
hour = "0" + hour;
var minute = date.getMinutes();
if (minute < 10)
minute = "0" + minute;
var second = date.getSeconds();
if (second < 10)
second = "0" + second;
return "" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":" + second;
}