JS以指定格式获取当前日期


 1 //获取当前时间,格式YYYY-MM-DD
 2     function getNowFormatDate() {  3         var date = new Date();  4         var seperator1 = "-";  5         var year = date.getFullYear();  6         var month = date.getMonth() + 1;  7         var strDate = date.getDate();  8         if (month >= 1 && month <= 9) {  9             month = "0" + month; 10  } 11         if (strDate >= 0 && strDate <= 9) { 12             strDate = "0" + strDate; 13  } 14         var currentdate = year + seperator1 + month + seperator1 + strDate; 15         return currentdate; 16     }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM