xenium
asked on
Creating a dynamic URL - set dates to upcoming weekend
hi,
I'd like to amend the solution to the following question so that check-in and check-out dates are set to the next Friday/Sunday respectively (and if today is Friday then today till Sunday)
https://www.experts-exchange.com/questions/28992516/Creating-a-dynamic-URL-link-to-results-on-Airbnb-availability-for-tomorrow.html
What edit do I need to this javascript? (thank you Shaun Vermaak)
Thanks
I'd like to amend the solution to the following question so that check-in and check-out dates are set to the next Friday/Sunday respectively (and if today is Friday then today till Sunday)
https://www.experts-exchange.com/questions/28992516/Creating-a-dynamic-URL-link-to-results-on-Airbnb-availability-for-tomorrow.html
What edit do I need to this javascript? (thank you Shaun Vermaak)
javascript:function url() {
var startDate = new Date();
startDate.setDate(startDate.getDate() + 1);
var y = startDate.getFullYear();
var m = startDate.getMonth() + 1;
if (m < 10) {
m = '0' + m;
}
var d = startDate.getDate();
if (d < 10) {
d = '0' + d;
}
var startString = d + "-" + m + "-" + y;
var endDate = new Date();
endDate.setDate(startDate.getDate() + 2);
y = endDate.getFullYear();
m = endDate.getMonth() + 1;
if (m < 10) {
m = '0' + m;
}
d = endDate.getDate();
if (d < 10) {
d = '0' + d;
}
var endString = d + "-" + m + "-" + y;
return 'https://www.airbnb.co.uk/s/Chippenham--UK?source=hdr&place_id=ChIJXdTdiABjcUgRSYcPSszcRq8&checkin=' + startString + '&checkout=' + endString + '&adults=2&children=0&infants=0&guests=2&room_types%5B%5D=Entire%20home%2Fapt&allow_override%5B%5D=&page=1&s_tag=JioWJWEX'
} window.open(url(),"_blank");
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great thanks again!
Are the variations 1-3 trivial or should i post a follow-up?
Thanks
Are the variations 1-3 trivial or should i post a follow-up?
Thanks
ASKER
ASKER
followup next MOnday to following Monday (7 nights) https://www.experts-exchange.com/questions/28992530/Creating-a-dynamic-URL-set-dates-to-next-Monday-to-following-Monday.html
ASKER
follow-up next MOnday till 28 days later https://www.experts-exchange.com/questions/28992531/Creating-a-dynamic-URL-set-dates-to-next-Monday-till-28-days-later.html
ASKER
1. check-in next week Monday, check-out Friday
2. check-in next week Monday, check-out following Monday
3. check-in next week Monday, check-out 28 days later