1. 程式人生 > >js獲取時間按照年月如時分秒

js獲取時間按照年月如時分秒

var myDate=new Date();
var date=myDate.getFullYear()+'-'/*年*/
	+((myDate.getMonth()+1)<10?"0"+
	    (myDate.getMonth()+1):(myDate.getMonth()+1))+'-'/*月*/
	+(myDate.getDate()<10?"0"+
	    (myDate.getDate()):myDate.getDate())+" "/*日*/
	+formatterData(myDate.getHours())+":"/*小時*/
	+formatterData(myDate.getMinutes())+":"/*分鐘*/
	+formatterData(myDate.getSeconds());/*秒*/