JS如何获取当前日期YYYY-MM-DD格式?
程序员文章站
2023-09-19 15:50:21
js如何获取当前日期yyyy-mm-dd格式?
function gettoday(){
var date = new date();...
js如何获取当前日期yyyy-mm-dd格式?
function gettoday(){ 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; }
上一篇: 难以坚持的事情