js如何实现日期格式转换?急~
现在能得到UTC格式的日期
想转换为yy-MM-dd hh:mm:ss格式
如何转换 谢谢
------解决方案-------------------- <script language= "javascript ">
function testGG(){
var xxx = new Date();
var xYear = xxx.getYear().toString();
xYear = xYear.substr(2,2);
var xMonth = xxx.getMonth();
if(xMonth < 10){
xMonth = "0 " + xMonth;
}
var xDay = xxx.getDay();
if(xDay < 10){
xDay = "0 " + xDay;
}
var xHours = xxx.getHours();
if(xHours < 10){
xHours = "0 " + xHours;
}
var xMinutes = xxx.getMinutes();
if(xMinutes < 10){
xMinutes = "0 " + xMinutes;
}
var xSeconds = xxx.getSeconds();
if(xSeconds < 10){
xSeconds = "0 " + xSeconds;
}
var xDate = xYear+ "- "+xMonth+ "- "+xDay+ " "+xHours+ ": "+xMinutes+ ": "+xSeconds
alert(xDate);
}
</script>
<input type= "button " value= "showDate " onClick= "testGG() ">