react-date-object
react-date-object copied to clipboard
date doesn't return the value. it returns empty object
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 ..
Can you provide a code sand box link?
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.