hi,i have some function about date object of javascript,u can see it to use..setUTCDate() Sets the day of the month in a Date object according to universal time (from 1-31) setUTCMonth() Sets the month in a Date object according to universal time (from 0-11) setUTCFullYear() Sets the year in a Date object according to universal time (four digits) setUTCHours() Sets the hour in a Date object according to universal time (from 0-23) setUTCMinutes() Set the minutes in a Date object according to universal time (from 0-59) setUTCSeconds() Set the seconds in a Date object according to universal time (from 0-59)
setUTCMilliseconds()
in your example,firstly, u need to use split make the UTC string to the Array;then u can new date() to call that functions to slove ur problem.
//格式化时间 Thu May 8 12:12:12 UTC+0800 2008 转换成 2008-5-12 12:12:12 。 function formatDateFromUTC(utcDate) { var date=new Date(utcDate); var yy=date.getFullYear ();
setUTCMilliseconds()
{
var date=new Date(utcDate);
var yy=date.getFullYear ();
var MM=date.getMonth ()+1;
if(MM<10)
{
MM="0"+MM;
}
var dd=date.getDate ();
if(dd<10)
{
dd="0"+dd;
}
// var hh=date.getHours ();
//
// if(hh<10)
// {
// hh="0"+hh;
// }
// var mm=date.getMinutes();
// if(mm<10)
// {
// mm="0"+mm
// }
// var ss=date.getSeconds ();//02
// if(ss<10)
// {
// ss="0"+ss;
// }
return yy+"-"+MM+"-"+dd;
}