1

I have some problem when I want to get the date from JSON that output in format 31-10-2019 07:00:00, I want to change that format to YYYY-MM-DD, but at the moment, the field still displays dd/mm/yyyy, for more detail look at my code :

<FormGroup>
    <Label for="expiredDate">Expired Date</Label>
    <Input
        type="date"
        name="expiredDate"
        onChange = {this.handleForm}
        value = {moment(new Date(expiredDate)).format("YYYY-MM-DD")}
        placeholder="date placeholder"
        min = {moment().format("YYYY-MM-DD")}/>
</FormGroup>

IN User Interface

Fixed it with moment(expiredDate, 'DD/MM/YYYY hh:mm:ss').format('YYYY-MM-DD')

Dženis H.
  • 7,284
  • 3
  • 25
  • 44

0 Answers0