This is the data that is console.log(values).
city: "abc"
departmentId: "humanResources"
email: "123@gmail.com"
facebook: ""
fullName: "afdasf"
gender: "male"
hireDate: Fri Aug 06 2021 21:30:00 GMT+0630 (Myanmar Time) {}
__proto__: Object
isPermanent: true
mobile: "65689189789"
otherDepartment: ""
university: "abcde"
__proto__: Object
But when I push the data into firebase, I get all the other data except for the hireDate. I use DateFnsUtils from "@date-io/date-fns" react library for getting the date. Here is the data from the firebase.
city: "abc"
departmentId: "humanResources"
email: "123@gmail.com"
facebook: ""
fullName: "afdasf"
gender: "male"
isPermanent: true
mobile: "65689189789"
otherDepartment: ""
university: "abcde"
From a quick glance it looks like your hireDate
property is a Date
object. While that is a valid JavaScript object, it is not a valid JSON object and Firebase Realtime Database can only store JSON objects.
The idiomatic way to solve this is by storing the timestamp of the data, which is the number of milliseconds since the epoch. You can get this value from a Date
by calling the getTime()
method on it.