I am trying to create a testing script in Selenium and I need to enter a date. I have figured out how to get the dates using:
storeEval var d=new Date(); d.getDate() CurrentDay
store Eval var m=new Date(); (m.getMonth()+1) CurrentMonth
storeEval var y=new Date(); y.getFullYear() CurrentYear
Now I want want to create variables for times in the past and future. I have been told I can do so using milliseconds, which is amazing but the closest I can come is this:
storeEval new Date().getTime()+604800000 //604800000- being 7 days in the future
I get back: 1350932638018 which is 7 days forward according to this amazing calculator I found.
So, how do I take the number I found and extract the date, month and year as I did for today’s date.
If your future date is stored in the variable
dthen it should be as easy as:or if it isn’t stored in a variable, then maybe something like this?
And then now
nis a date object and you should be able to use the.getFullYear()methods.Take a look at this fiddle and see if it helps: http://jsfiddle.net/wVVmw/