JScript code
<script type="text/javascript"> //取当前时间,格式为,yyyy-mm-dd hh:mm:ss function GetDateT() { var d,s; d = new Date(); s = d.getYear() + "-"; //取年份 s = s + (d.getMonth() + 1) + "-";//取月份 s += d.getDate() + " "; //取日期 s += d.getHours() + ":"; //取小时 s += d.getMinutes() + ":"; //取分 s += d.getSeconds(); //取秒 return(s); } myDate=GetDateT() alert (myDate) </script>
<div id="jnkc"> </div> <script>setInterval("jnkc.innerHTML=new Date().toLocaleString();",1000); </script>
<script>
var today =new Date()
alert((today.toLocaleString().replace(/年|月/g,'-')).replace(/日/g,''))
</script>
<script>
var today =new Date()
alert((today.toLocaleString().replace(/年|月/g,'-')).replace(/日/g,''))
</script>