Creating a dynamic URL - link to results on Airbnb availability for tomorrow

hi,
I'm looking to create a link to a URL that can update automatically using today's date. Reason is I want to monitor the pricing on my Airbnb listings without having to type in all the search dates every time. So I'd like a URL which is essentially as below but with dates that update to say for example checkin=  ** tomorrow ** &checkout= ** two days later **

https://www.airbnb.co.uk/s/Chippenham--UK?source=hdr&place_id=ChIJXdTdiABjcUgRSYcPSszcRq8&checkin=02-01-2017&checkout=05-01-2017&adults=2&children=0&infants=0&guests=2&room_types%5B%5D=Entire%20home%2Fapt&allow_override%5B%5D=&page=1&s_tag=JioWJWEX


Is there an easy way to do this, perhaps even an expression that the browser itself can parse.

Thanks

PS I've added the javascript topic as I'm interested to learn this and if this is a viable method then this could be a good test
xeniumAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun VermaakTechnical Specialist/DeveloperCommented:
Just alter the below code
javascript:function url() {
 var date = new Date();
 var y = date.getFullYear(); 
 var m = date.getMonth() +1; 
 if(m < 10){m = '0' + m;}
 var d = date.getDate();
 if(d < 10){d = '0' + d;}
 var date = y + "-" + m + "-" + d;

 return 'https://www.google.com/analytics/web/?authuser=0#my-reports/XXXXXXXX/XXXXXXXXXXX/%3F_u.date00%3D'+ date +'%26_u.date01%3D'+ date +'/';

} window.open(url(),"_blank");

Open in new window


Can also be used as a bookmark.
http://trendblog.net/how-to-create-a-dynamic-bookmark-with-todays-date-in-the-url/
0
xeniumAuthor Commented:
Great thanks, that works nicely! I'm new to Javascript so I just need to make some more adjustments for my case.. how would I do today +1 and today + 3? I've done a simple version below but it only works within the same month..

javascript:function url() {
 var date = new Date();
 var y = date.getFullYear(); 
 var m = date.getMonth() +1; 
 if(m < 10){m = '0' + m;}
 var d1 = date.getDate()+1;
 var d2 = date.getDate()+3;
 if(d1 < 10){d1 = '0' + d1;}
 if(d2 < 10){d2 = '0' + d2;}
 var CIdate = d1 + "-" + m + "-" + y;
 var COdate = d2 + "-" + m + "-" + y;

 return 'https://www.airbnb.co.uk/s/Chippenham--UK?source=hdr&place_id=ChIJXdTdiABjcUgRSYcPSszcRq8&checkin='+ CIdate +'&checkout='+ COdate +'&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");

Open in new window

0
Shaun VermaakTechnical Specialist/DeveloperCommented:
Here is updated code
javascript:function url() {
var startDate = new Date();
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() + 3);
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");

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

xeniumAuthor Commented:
Thanks, just a slight change.. start date needs to be tomorrow (today +1) and end date 2 days later (today +3)

I tried editting your code but fell on the first bit

thanks
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
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");

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
xeniumAuthor Commented:
Great thanks, that's perfect!
0
xeniumAuthor Commented:
PS I have a follow-up I'll post a link to a separate question in a moment
0
xeniumAuthor Commented:
This solution opens an additional blank tab by mistake, not a big issue but is there an easy way to avoid this?
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
Change
window.open(url(),"_blank");

Open in new window

to
window.open(url(),"_self");

Open in new window

1
xeniumAuthor Commented:
Great thanks a lot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.