Html 5 code

Hi,

I cannot get this script to show the date and time. Tried IE, Safari and Chrome. What is wrong?

Trying the learn Javascript with html and this is the first exercise!

Need help.

Regards

Chris

<!DOCTYPE html>

<html lang=“en”>
	<head>
		<title>Displaying Time and Dates</title>
	</head>

	<body>
		<h1>Current Date and Time</h1>
	<script type=“text/javascript”>
	now = new Date();
	localtime = now.toString();
	utctime = now.toGMTString();
	document.write(“<p><strong>Local time:</string> “ + localtime + “</p>”);
	document.write(“<p><strong>UTC time:</strong> “ utctime + “</p>”);
	</script>
	</body>
</html>

Open in new window

CMChalcraftFinance DirectorAsked:
Who is Participating?
 
CMChalcraftFinance DirectorAuthor Commented:
Hi,

Thanks for that. Amazing what you miss. String for Strong! I will try and look out for the normal quotes in the future.

I started using Pages for the html coding as I prefer using the Mac to Windows. I then found TextEdit on the Mac which I used for this. However I wonder now if I should just use Notepad.

Anyway it works. So onto the next scripting lesson.

Regards

Chris
0
 
Mark BullockQA Engineer IIICommented:
I changed your smart quotes (probably from Word) to normal quotes.
I fixed the first closing tag for strong.
And this displays the date and time.
<!DOCTYPE html>

 <html lang="en">
       <head>
             <title>Displaying Time and Dates</title>
       </head>

       <body>
             <h1>Current Date and Time</h1>
       <script type="text/javascript">
       now = new Date();
       localtime = now.toString();
       utctime = now.toGMTString();
       document.write("<p><strong>Local time:</strong> "+ localtime + "</p>");
       document.write("<p><strong>UTC time:</strong> " + utctime + "</p>");
       </script>
       </body>
 </html> 

Open in new window

0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
CMChalcraft, did you mean to give Mark the points for this?  

Also, a very good text editor for mac http://www.barebones.com/products/textwrangler/ (free)  http://brackets.io/ (free)  https://www.jetbrains.com/webstorm/
0
 
CMChalcraftFinance DirectorAuthor Commented:
Very quick response.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.