在脚本中怎样把UTC国际时间转换成本地时间
比如Mon Mar 9 20:30:07 UTC+0800 2009 
怎样把它转成2009-3-某日 20:30:07 的形式呢,
请大家帮忙

解决方案 »

  1.   

    function   Todate(num)
    { //Fri Oct 31 18:00:00 UTC+0800 2008
    num=num+"";
    var date="";
    var month=new Array();
    month["Jan"]=1;month["Feb"]=2;month["Mar"]=3;month["Apr"]=4;month["May"]=5;month["Jan"]=6;
    month["Jul"]=7;month["Aug"]=8;month["Sep"]=9;month["Oct"]=10;month["Nov"]=11;month["Dec"]=12;
    var week=new Array();
    week["Mon"]="一";week["Tue"]="二";week["Wed"]="三";week["Thu"]="四";week["Fri"]="五";week["Sat"]="六";week["Sun"]="日";
    str=num.split(" ");
    date=str[5]+"年";
    date=date+month[str[1]]+"月"+str[2]+"日 "+str[3];
    date=date+" 周"+week[str[0]];
    return date;
    }
      

  2.   

                    Date.prototype.format = function(format) //author: meizz
                    {
                      var o = {
                        "M+" : this.getMonth()+1, //month
                        "d+" : this.getDate(),    //day
                        "h+" : this.getHours(),   //hour
                        "m+" : this.getMinutes(), //minute
                        "s+" : this.getSeconds(), //second
                        "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
                        "S" : this.getMilliseconds() //millisecond
                      }
                      if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
                        (this.getFullYear()+"").substr(4 - RegExp.$1.length));
                      for(var k in o)if(new RegExp("("+ k +")").test(format))
                        format = format.replace(RegExp.$1,
                          RegExp.$1.length==1 ? o[k] : 
                            ("00"+ o[k]).substr((""+ o[k]).length));
                      return format;
                    }
    Date d = new Date();
    document.write(d.format("yyyy-MM-dd"));
      

  3.   

       Date.prototype.format = function(format) //author: meizz
                    {
                      var o = {
                        "M+" : this.getMonth()+1, //month
                        "d+" : this.getDate(),    //day
                        "h+" : this.getHours(),   //hour
                        "m+" : this.getMinutes(), //minute
                        "s+" : this.getSeconds(), //second
                        "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
                        "S" : this.getMilliseconds() //millisecond
                      }
                      if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
                        (this.getFullYear()+"").substr(4 - RegExp.$1.length));
                      for(var k in o)if(new RegExp("("+ k +")").test(format))
                        format = format.replace(RegExp.$1,
                          RegExp.$1.length==1 ? o[k] : 
                            ("00"+ o[k]).substr((""+ o[k]).length));
                      return format;
                    }
    Date d = new Date();
    document.write(d.format("yyyy-MM-dd"));
      

  4.   

      <script type="text/javascript">
    function CurentTime()
        { 
            var now = new Date();
           
            var year = now.getFullYear();       //年
            var month = now.getMonth() + 1;     //月
            var day = now.getDate();            //日
           
            var hh = now.getHours();            //时
            var mm = now.getMinutes();          //分
           
            var clock = year + "-";
           
            if(month < 10)
                clock += "0";
           
            clock += month + "-";
           
            if(day < 10)
                clock += "0";
               
            clock += day + " ";
           
            if(hh < 10)
                clock += "0";
               
            clock += hh + ":";
            if (mm < 10) clock += '0'; 
            clock += mm; 
            return(clock); 
        } var myTime = CurentTime();
      alert(myTime);
      </script>