我想知道是否可以将下面的日期修改为提前2周阅读,而不是阅读实际日期?
<script language="JavaScript">
var now = new Date();
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var monNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
document.write(" " + dayNames[now.getDay()] + " " + monNames[now.getMonth()] + " " + now.getDate() + ", " + now.getFullYear());
</script>
<!--End Date Script-->
答案 0 :(得分:0)
var daysToAdd = 14;
var myDate = new Date(new Date().getTime()+(daysToAdd * 24 * 60 * 60 *1000));
var output = [
dayNames[myDate.getDay()],
monNames[myDate.getMonth()],
myDate.getDate(),
].join(' ') + ', ' + myDate.getFullYear(); // "Thursday April 23, 2015"