0

how do i Get current date in Mon-DD-YYY format in JavaScript, i am trying to enter todays date without time in a date picker field

below is my current code and it is failing

  Page.prototype.clickOnsessionDate = async function () {
  const request = await this.findByXpath(clickOnsessionDate);
  await this.write(reques, Date());
  await this.driver.sleep(5000);

};

tech2
  • 1

1 Answers1

0

You could do this:

var date = new Date();
    alert(((date.getMonth() > 8) ? (date.getMonth() + 1) : ('0' + (date.getMonth() + 1))) + '/' + ((date.getDate() > 9) ? date.getDate() : ('0' + date.getDate())) + '/' + date.getFullYear());