js获取时间按照年月如时分秒

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Smy_0114/article/details/82751691
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());/*秒*/

猜你喜欢

转载自blog.csdn.net/Smy_0114/article/details/82751691