- var date = new Date(); //日期对象
-
var now = "";
-
now = date.getFullYear()+"-";
-
now = now + ((date.getMonth()+1)<10?"0"+(date.getMonth()+1):(date.getMonth()+1)) +"-";
-
now = now + (date.getDate()<10?"0"+date.getDate():date.getDate()) +" ";
-
now = now + (date.getHours()<10?"0"+date.getHours():date.getHours()) +":";
-
now = now + (date.getMinutes()<10?"0"+date.getMinutes():date.getMinutes()) +":";
-
now = now + (date.getSeconds()<10?"0"+date.getSeconds():date.getSeconds()) +"";
-
alert(now);
输出的结果是 2011-05-05 15:21:40
阅读(702) | 评论(0) | 转发(0) |