从现在起11天

时间:2012-07-14 19:36:09

标签: javascript date

我知道有一些关于这个主题的类似帖子,但没有一个对我帮助太大(或者可能是因为我还是新手)。

无论如何,我正在寻找的是一个剧本,向我展示从现在起11天后的日期和日期。

以下脚本是我用来显示当前日期和日期。所以我认为必须有一些简单的行来添加或修改某个地方?比如“+11”

非常感谢任何有用的答案!


var daynames = new Array( "Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday");

var months = new Array( "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december");

var currentTime = new Date();

var dayname = currentTime.getDay();

var month = currentTime.getMonth();

var day = currentTime.getDate();

var year = currentTime.getFullYear();

document.write(daynames[dayname] + "<BR> " + day  + " " + months[month]  + " " + year);

2 个答案:

答案 0 :(得分:2)

假设您正在使用JavaScript,此代码段会将d设置为当天的+11天 -

var d = new Date();
d.setDate(d.getDate()+11);

答案 1 :(得分:1)

假设javascript是因为document.write

var yourDate=new Date();
yourDate.setDate(yourDate.getDate()+11); //11 is the number of days you want to add

参考:getDatesetDate