Show date time in a field


Hi guys

if I have this code in HTML

how to get the date time from my PC automatically??
FYI: I don’t know how to connect a js file into my index!!


You can use the Javascript Date() instance to get the current time.
You can also link to a js file by using the script src tag in your header or body.

This example shows a simple way to use the Date() instance as well as link to external CSS/JS:

<!doctype html>
<html lang="en">
  <link rel="stylesheet" href="path/to/css/styles.css">
  <script src="path/to/js/scripts.js"></script>

  <span id="time"></span>
    document.getElementById('time').textContent = new Date();


Coincidentally I made a little function this week that displays today’s date like this: Sunday July 30, 2017.
I like that format on a page. Here it is if you want to try it:

//Today's Date function (Day of week Month Day, Year):

var todayDate = function() {
  var months = [

  var weekDays = [
  var x = new Date();
  var day = x.getDate();
  var weekday = weekDays[x.getDay()];
  var month = months[x.getMonth()];
  var year = x.getFullYear();
  var today = weekday + " " + month + " " + day + ", " + year;
  return today;