i'm using a React component called DateRangePicker (DRP)
, so when i choose a date an update my state and console log it, it shows me an object like below,
CheckIn: F
_d: Fri Aug 21 2020 12:00:00 GMT+0430 (Iran Daylight Time) {}
_isAMomentObject: true
_isUTC: false
_isValid: true
_jDiff: 0
_locale: Locale {_calendar: {…}, _longDateFormat: {…}, _invalidDate: "Invalid date", _ordinal: "%dم", _dayOfMonthOrdinalParse: /\d{1,2}/, …}
_pf: {empty: false, unusedTokens: Array(0), unusedInput: Array(0), overflow: -2, charsLeftOver: 0, …}
__proto__: Moment
but i want to extract the date i chose from it, so how can i accomplish this?
Ciao, you see this because the return value of DateRangePicker
is a moment object (_isAMomentObject: true
). If you want a date in a certain format you could do:
(supposing that value returned is called value)
value.format('YYYY-MM-DD'); //format YYYY-MM-DD