js獲取當(dāng)前年月日-YYYYmmDD格式的實(shí)現(xiàn)代碼
來源:易賢網(wǎng) 閱讀:4658 次 日期:2016-06-17 14:23:20
溫馨提示:易賢網(wǎng)小編為您整理了“js獲取當(dāng)前年月日-YYYYmmDD格式的實(shí)現(xiàn)代碼”,方便廣大網(wǎng)友查閱!

下面小編就為大家?guī)硪黄猨s獲取當(dāng)前年月日-YYYYmmDD格式的實(shí)現(xiàn)代碼。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。

js獲取當(dāng)前年月日-YYYYmmDD格式的實(shí)現(xiàn)代碼

代碼如下:

var nowDate = new Date();

 var year = nowDate.getFullYear();

 var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1)

  : nowDate.getMonth() + 1;

 var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate

  .getDate();

 var dateStr = year + "-" + month + "-" + day;

以上這篇js獲取當(dāng)前年月日-YYYYmmDD格式的實(shí)現(xiàn)代碼就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考

更多信息請查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機(jī)網(wǎng)站地址:js獲取當(dāng)前年月日-YYYYmmDD格式的實(shí)現(xiàn)代碼
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn)

版權(quán)所有:易賢網(wǎng)