Check Flight Prices for Next Week

Someone asked if it is possible to view the flight prices for next week. Obviously one could go to a website like kayak, input the flight dates and view the prices. But, if you want to do this every day you will have to enter the dates every day. Therefore I came up with a simple script which produces a website with a link that opens up a kayak searh for a flight in 7 days from now.

In this example it searches for a flexible (+-2 days) return flight is from FRA to NYC with a 5 day stay in New York.

<!DOCTYPE html>

<p id="demo"></p>

var date = new Date();
var dateEnd = new Date();

date.setTime(date.getTime() + 7*24*60*60*1000); // in 7 days from now
dateEnd.setTime(date.getTime() + 5*24*60*60*1000); // travel for 5 days

// zero padding and +1 because javascript counts months from 0
var d = ("00" + date.getDate()).slice(-2);
var m = ("00" + (date.getMonth()+1)).slice(-2);
var y = date.getFullYear();

var de = ("00" + dateEnd.getDate()).slice(-2);
var me = ("00" + (dateEnd.getMonth()+1)).slice(-2);
var ye = dateEnd.getFullYear();

document.getElementById("demo").innerHTML = "<a href="+y+"-"+m+"-"+d+"-flexible/"+ye+"-"+me+"-"+de+"-flexible>Link to KAYAK +7 days</a>";