JS获取日期yy-mm-dd格式
2020-12-12 23:33
标签:blog class code java c get 方法一: 方法二: JS获取日期yy-mm-dd格式,搜素材,soscw.com JS获取日期yy-mm-dd格式 标签:blog class code java c get 原文地址:http://www.cnblogs.com/littleCode/p/3708380.html
var
myDate=
new
Date();
var
month = myDate.getMonth() + 1;
var
Day = myDate.getDate();
var
today =
""
;
if
(month
if
(Day
today = myDate.getFullYear() +
"-0"
+ month +
"-0"
+ Day;
}
else
{
today = myDate.getFullYear() +
"-0"
+ month +
"-"
+ Day;
}
}
else
{
if
(Day
today = myDate.getFullYear() +
"-"
+ month +
"-0"
+ Day;
}
else
{
today = myDate.getFullYear() +
"-"
+ month +
"-"
+ Day;
}
}
function
appendZero(s){
return
(
"00"
+ s).substr((s+
""
).length);}
//补0函数
var
d =
new
Date();
alert(d.getFullYear() +
"-"
+ appendZero(d.getMonth() + 1) +
"-"
+ appendZero(d.getDate()));