date picker get value in dd/mm/yyyy format in mdb react


Topic: date picker get value in dd/mm/yyyy format in mdb react

viswanathm pro premium asked 4 days ago

hi,

i want date in dd/mm/yyyy format in react application. currently i am getting get value as Mon Jul 15 2019 18:13:00 GMT+0530 (India Standard Time)

how to use $('.datepicker').pickadate({ format: 'yyyy/mm/dd', formatSubmit: 'yyyy/mm/dd' }) in mdbreact or there is any other way.


Hi,

Datepicker receives format property, where you can set any format you want. For example:

import React from 'react';
import { MDBDatePicker } from 'mdbreact';

class DatePickerPage extends React.Component  {
  getPickerValue = (value) => {
    console.log(value);
  }

  render() {
    return(
      <div>
        <MDBDatePicker format="YYYY / MM / DD" getValue={this.getPickerValue} />
      </div>
    );
  }
};

export default DatePickerPage;

Notice that register, a count of letters and spaces affects the date you will get:

format="M / D/YY" will set data as `7 / 12/19`
format="D MMMM, Y" will set data as `12 July, 2019`

Hope I could help you.

Best regards.


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: React
  • MDB Version: 4.18.0
  • Device: laptop
  • Browser: chrome
  • OS: windows
  • Provided sample code: No
  • Provided link: No