Convert an input type time, to a timestamp for firestore
<input type="time" class="form-control job-field" id="starttime" name="starttimeadd" placeholder="Job Start Time" required>
This is what I have tried but no luck, I did have a couple of results trying a different method but that showed an invalid date or NaN.
var starttimestamp = moment.utc(moment("#starttimeadd")).format();
This is the expected result
This is my code
function addJob(){
var starttimeadd = $('#starttimeadd').val();
const starttimestamp = moment.utc(moment(starttimeadd)).format();
db.collection("jobs").doc().set({
starttime: starttimestamp,
})
.then(function() {
console.log("Document successfully written!");
})
.catch(function(error) {
console.error("Error writing document: ", error);
});
}
