获取当前日期方法 发表于 2019-03-01 | 分类于 function JS 获取当前日期方法 1234567891011121314151617181920212223242526272829303132333435//yyyy-mm-dd hh:mm:ssgetNowFormatDate: function () { var date = new Date(); var seperator1 = "-"; var seperator2 = ":"; var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + date.getHours() + seperator2 + date.getMinutes() + seperator2 + date.getSeconds(); return currentdate; }, //yyyy-mm-dd getNowFormatDate: function () { var date = new Date(); var seperator1 = "-"; var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var currentdate = year + seperator1 + month + seperator1 + strDate; return currentdate; }, 本文地址:https://tonysteven.github.io/2019/03/01/getnowformatdate/转载请注明出处,谢谢! 坚持原创技术分享,您的支持将鼓励我继续创作! 打赏 微信支付 支付宝