0

I'm using MultiDatePicker to send multiple dates to my server, the console.log(date) show it in the intended format (2022/08/08) but when it is sent you get something like the next data, any help on sending the data on format yyyy/mm/dd or anything similar would be appreciated

"startingDate": [
1659934800000,
1661922000000,
1661317200000,
1661749200000,
1661058000000,
1660453200000,
1661230800000
],
import DatePicker, { DateObject } from "react-multi-date-picker";
import DatePanel from "react-multi-date-picker/plugins/date_panel"

const date = new DateObject().format()
const [startingDate, setStartingDate] = useState(date);

console.log(startingDate)
console.log(date)

<DatePicker 
  value={startingDate} 
  onChange={setStartingDate} 
  multiple
  name="startingDate"
  plugins={[
    <DatePanel />
  ]} />

chris
  • 27
  • 4

1 Answers1

0

This kind of format 1659934800000 for date is Date Format in milliseconds. To change this format into real Date format, you can simply call new Date(1659934800000).

Then with this date object, you can format to your specific needs. For more detailed docs, please check here.

Phillip
  • 170
  • 4