js 關於日期

new Date()  獲取當前的完整日期 : 如 2016-12-30get

new Date().getFullYear() 獲取當前的年份im

new Date().getMonth() 獲取當前的月份(0-11) 注意: 能夠用: new Date().getMonth() + 1時間

new Date().getDate() 獲取當前是這個月的哪一號 ,如 2016-12-30 就會獲得 30  co

new Date().getDay(); //獲取當前星期X(0-6,0表明星期天)time

new Date().getTime(); //獲取當前時間(從1970.1.1開始的毫秒數)new

new Date().getHours(); //獲取當前小時數(0-23)日期

new Date().getMinutes(); //獲取當前分鐘數(0-59)

new Date().getSeconds(); //獲取當前秒數(0-59)

new Date().getMilliseconds(); //獲取當前毫秒數(0-999)

new Date().toLocaleDateString(); //獲取當前日期

var mytime=new Date().toLocaleTimeString(); //獲取當前時間

myDate.toLocaleString( ); //獲取日期與時間

相關文章
相關標籤/搜索