0

I can get the current date if I use this...

command: storeEval
Target: var d=new Date(); ('0' + (d.getMonth()+1)).slice(-2)+'/'+('0' + d.getDate()).slice(-2) + '/' +d.getFullYear()
Value: testdate

Actual Result > 05/14/2015

BUT I need the next date and it is not appearing the format that I wanted. Let say today's date is 05/14/2015, so I need an output of 05/15/2015. This is what I have as failing

command: storeEval
Target: var d=new Date(); ('0' + (d.getMonth()+1)).slice(-2)+'/'+(d.setDate(d.getDate() + 1)) + '/' +d.getFullYear()
Value: testdate

Actual Result > 05/1431642394763/2015
Expected Result > 05/15/2015

*Also above I didn't mention about the slice, I need that to work as well if the days go to 1-9.

Please help I need this step in Selenium IDE, any suggestions.

Gabriele Petrioli
  • 191,379
  • 34
  • 261
  • 317
Max Smith
  • 65
  • 1
  • 2
  • 12
  • The return value from [*setDate*](http://ecma-international.org/ecma-262/5.1/#sec-15.9.5.36) is the new time value, not the Date object the method was called on, so you can't chain it like that. You'd need to so something like `(new Date(d.setDate(d.getDate() + 1)).getDate())` but that looks hideous. – RobG May 13 '15 at 22:38
  • possible duplicate of [Add days to DateTime](http://stackoverflow.com/questions/563406/add-days-to-datetime) – tcigrand May 13 '15 at 22:41
  • @AnotherDev—I think the OP is cool with adding the day, just didn't realise what the return value from the *setDate* method was. – RobG May 13 '15 at 22:50
  • http://stackoverflow.com/questions/9444745/javascript-how-to-get-tomorrows-date-in-format-dd-mm-yy – DMart May 22 '15 at 19:19

1 Answers1

0

found the answer at JavaScript how to get tomorrows date in format dd-mm-yy

command: storeEval
Target: var d= new Date(new Date().getTime() + (86400000 *2)); ('0' + (d.getMonth()+1)).slice(-2)+'/'+('0' + d.getDate()).slice(-2) + '/' +d.getFullYear()
Value: testdate

Expected and Actual Result > 05/16/2015

Community
  • 1
  • 1
Max Smith
  • 65
  • 1
  • 2
  • 12