Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Uncaught ReferenceError: DateTime is not defined HTML

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any idea please?

>Solution :

Instead of using DateTime, you should be using Date. Note that 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.

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 = Date.toUTCString();
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading