我在网上找到了此代码。我试图用它写从今天起9天的日期,但是我不知道该怎么做。有谁知道该代码中要更改的内容吗?

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

var m_names = new Array("January ", "February ", "March ",
"April ", "May ", "June ", "July ", "August ", "September ",
"October ", "November ", "December ");

var d = new Date();
var curr_day = d.getDay();
var curr_date = d.getDate();
var sup = "";
if (curr_date == 1 || curr_date == 21 || curr_date ==31)
   {
   sup = "st";
   }
else if (curr_date == 2 || curr_date == 22)
   {
   sup = "nd";
   }
else if (curr_date == 3 || curr_date == 23)
   {
   sup = "rd";
   }
else
   {
   sup = "th";
   }
var curr_month = d.getMonth();
var curr_year = d.getFullYear();

document.write(d_names[curr_day] + " " + m_names[curr_month] + curr_date + "<SUP>" +     sup   + "</SUP> " + " " + curr_year);


日期的格式如下:2011年8月20日,星期六

最佳答案

之后:

var d = new Date();


写:

d.setDate(d.getDate()+9);


所以你有了:

var d = new Date();
d.setDate(d.getDate()+9);
var curr_day = d.getDay();
var curr_date = d.getDate();

关于javascript - 使用Javascript书写 future 的一天,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7135460/

10-12 05:51