js如何取當前日期時間/格式爲:yyyy-mm-dd hh:mm:ss

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>
相關文章
相關標籤/搜索