0

How do I extract a yyyy-mm-dd timestamp from the following?

handleDateChange = e => {}

<Form.Group as = {Col}>
  <Form.Control
    type = "date"
    value = { this.state.closingDate }
    onChange = { this.handleDateChange }
  />
</Form.Group>

At the moment e.timeStamp gives me a four or five digit number.

kcon123
  • 460
  • 2
  • 5
  • 13
  • https://stackoverflow.com/questions/19709793/convert-date-from-dd-mm-yyyy-to-yyyy-mm-dd-in-javascript - this should help – Monica Acha Feb 05 '20 at 11:54

1 Answers1

0

Try this:

  handleDateChange = e => {
    const date = new Date(e.target.value);
    const timestamp = date.getTime();

    console.log(timestamp)

    this.setState({
      closingDate: e.target.value
    })
  }

Edit great-hamilton-qh8x1

awran5
  • 4,333
  • 2
  • 15
  • 32