STATE OF CURRENT DATE
const [date, setDate] = React.useState(new Date())
console.log('date', date);
DATE CAN’T PUSHED TO FIREBASE DATABASE AND HOW TO PUSH DATE IN REALTIME DATABASE.
function addNewPerson() {
push(ref(db, '/addperson'), {
// addperson: value,
// value,
'Name': name,
'Room_no': selectedRoomNo,
'Contact': contact,
'Address': address,
'Image': fetchImage,
'Advanced_amount': advancedAmount,
'Date': date,
});
// setPresentTodo('');
}
2
Answers
You can add like below:
new Date()
is a function you can’t directly store the date function you need to convert it into a string and then it can be stored in the database