-2

Here is a set of code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 

<html xmlns="www.w3.org/1999/xhtml" xml:lang="en">


<title>Lots of Time</title>
<body>
<h1>Times</h1>
<script "type/javascript">
now = new Date();
localtime = now.toString();
utctime = now.toGMTString();
hours = now.getHours();
mins = now.getMinutes();
secs = now.getSeconds();
milli = now.getMilliseconds();
document.write("<h2>Local time:</h2> " + localtime + "<br/>");
document.write("<h2>UTC time</h2> " + utctime);
document.write("<h1>");
document.write(hours + ":" + mins + ":" + secs + ":" milli);
document.write("</h1>");
document.write("<h1>");
document.write(hours + ":" + mins + ":" + secs + ":" milli);
document.write("</h1>");
</script>

</body>
</html>

Everything worked fine until I added the line with the getMilliseconds();

Any help would be much appreciated. Sincerely, Erin

2 Answers2

1

Add a plus sign so it looks like:

document.write(hours + ":" + mins + ":" + secs + ":" + milli);
Jon Rubins
  • 4,323
  • 9
  • 32
  • 51
1

change

document.write(hours + ":" + mins + ":" + secs + ":" milli);

to

document.write(hours + ":" + mins + ":" + secs + ":" + milli);
Vahid Farahmand
  • 2,528
  • 2
  • 14
  • 20