<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
title
>Document
</
title
>
</
head
>
<
body
>
<
script
>
function
getDateStr(
dayCount){
if(
null ==
dayCount){
dayCount =
0;
}
var
dd =
new
Date();
dd.
setDate(
dd.
getDate()+
dayCount);
//设置日期
var
y =
dd.
getFullYear();
var
m =
dd.
getMonth()+
1;
//获取当前月份的日期
var
d =
dd.
getDate();
return
y+
"-"+
m+
"-"+
d;
}
document.
write(
"<br/> 昨天:" +
getDateStr(-
1));
document.
write(
"<br />今天:"+
getDateStr(
0));
document.
write(
"<br />明天:"+
getDateStr(
1));
document.
write(
"<br />后天:"+
getDateStr(
2));
<
/
script
>
</
body
>
</
html
>