Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Date Picker Problem ?

Group free asked 5 years ago


Hi there,

when I select the datepicker , i got this value " Thu Mar 21 2019 00:00:00 GMT+0600 (Bangladesh Standard Time)" , but I need exact this value "Thu Mar 21 2019" . how can I change date in mdbbootstarp reactjs? thanks


Aliaksandr Andrasiuk staff answered 5 years ago


Hello,

The value you get is a value of object Date. You can format it whatever you like using JavaScript. I recommend this free library https://date-fns.org/.

Example:

import React from 'react';
import { MDBDatePicker } from 'mdbreact';
import { format } from 'date-fns';

class DatePickerPage extends React.Component  {
  getPickerValue = (value) => {
    const myDate = format(value, 'ddd MMM DD YYYY');
    console.log(myDate);
  }

  render() {
    return(
      <div>
        <MDBDatePicker getValue={this.getPickerValue} />
      </div>
    );
  }
};

export default DatePickerPage;

Best regards,

Aliaksandr from MDB.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.8.7
  • Device: pc
  • Browser: chrome
  • OS: windows
  • Provided sample code: No
  • Provided link: No