I’m pretty new with HTML / JS
I have an HTML page like this
<script src="https://www.gstatic.com/firebasejs/8.8.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.8.1/firebase-firestore.js"></script>
<script>
const name = document.getElementById("name").value;
const email = document.getElementById("email").value;
const category = document.getElementById("categories").value;
const message = document.getElementById("message").value;
var now = new DateTime( DateTimeZone.UTC ).toString();
But I am getting an error in the console:
Uncaught ReferenceError: DateTime is not defined
I am not sure how to import DateTime in my html file.
Any idea please?
2
Answers
Instead of using DateTime, you should be using Date. Note that
new Date().toUTCString()
returns a string. I presume that you are using Firebase Firestore based on the above code. If so, this will be interpreted as a string field, not a timestamp field.Try to use this: