react-date-object icon indicating copy to clipboard operation
react-date-object copied to clipboard

date doesn't return the value. it returns empty object

Open mahtabfalahat opened this issue 2 years ago • 2 comments

hi, i'm using the package date picker in <DatePicker>, when i want to set the date value on state on onChange, it won't set and i just get an empty object : Object { }

how can i get the date value ? thanks ..

mahtabfalahat avatar Jul 03 '22 19:07 mahtabfalahat

Can you provide a code sand box link?

AliBayatMokhtari avatar Mar 26 '23 07:03 AliBayatMokhtari

I had this problem too, found the following workaround for extracting month:

function onMonthChange(date: DateObject | DateObject[] | null,
                         options: any) {
    if(date){
      const formattedMonth = `${date.year}-${date.month.number}`
      console.log(formattedMonth)
    }
  }

Even if it shows empty in browser console you can still extract properties like year, month, day, hour, minute and etc.

dragongling avatar Oct 19 '23 06:10 dragongling