I\'m testing my web application using Selenium IDE. There are test cases in which I have to assert that today\'s date appears on the page. I cannot hard code today\'s date in th
The line
works but returns the month as single-digit.var d=new Date(); d.getDate()+'-'+((d.getMonth()+1))+'-'+d.getFullYear();
For my test case, I need the date returned in the format YYYY-MM-DD, so I use
var d= new Date(); var m=((d.getMonth()+1)<10)?'0'+(d.getMonth()+1):(d.getMonth()+1); d.getFullYear()+"-"+m+"-"+d.getDate();