I am trying to push the date and time of Form Submission along with the email the user inputs. the email comes through but the date/time does not.
I have tried this so far ...
//Listen for form submit
document.getElementById('cta_form').addEventListener('submit', submitForm);
//Submit Form
function submitForm(e){
e.preventDefault();
//Get Valuse
var email = getInputVal('email');
var email_date = new Date();
console.log(email_date);
//save email
saveEmail(email,date);
//Show alert
document.querySelector('.alert').style.display = 'block';
//set alert timeout
setTimeout(function(){
document.querySelector('.alert').style.display = 'none';
},3000);
//Clear Form
document.getElementById('cta_form').reset();
}
//function to id values
function getInputVal(id){
return document.getElementById(id).value;
}
//Save emails to firebase
function saveEmail(email,email_date){
var newEmailRef = emailsRef.push();
newEmailRef.set({
email: email,
date: email_date,
});
}
I just want the date to show up as it does in console.log. e.g
Thu Aug 29 2019 22:18:47 GMT+0530 (India Standard Time)```