简体   繁体   中英

Insert today's date plus two days into text on a page (JavaScript?)

I'm making a small online (Squarespace) store for a farm.

I'd like to specify that items will be available for pickup two days after purchasing online (not immediately). Ideally, I could insert that date seamlessly into the text so that visitors don't have to do the math themselves. So it would say something like, "If you order by 9pm today, your order will be available for pickup after 9am on [TODAY'S DATE + 2 DAYS]."

How do I do this? Will it require Javascript?

I don't know much about coding at all, so I appreciate any guidance.

Tim

try this and see

Date.prototype.addDays = function(days) {
    var date = new Date(this.valueOf());
    date.setDate(date.getDate() + days);
    return date;
}

var date = new Date();

alert(date.addDays(5));

from here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM