var str = '2008-10-09 21:35:28';//PHP中对应的UNIX时间戳为1223559328 var new_str = str.replace(/:/g,'-'); new_str = new_str.replace(/ /g,'-'); var arr = new_str.split("-"); document.write("<b>原始日期</b>: "+str); var datum = new Date(Date.UTC(arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5])); document.write("<br><b>转换后的UNIX时间戳为</b>: "+(datum.getTime()/1000)); var datum = new Date(datum.getTime()); document.write("<br><b>还原到原始日期为</b>: "+datum.toLocaleString());