More about Date object
This is Continuation from previous post
You now that i have allready assigned Date() object in now variable(now=new Date(); ).So I can use all methods and all
properties of Date object in now.
You can found new line of code in this program.That is
hours=now.getHours();mins=now.getMinutes();secs=now.getSeconds();
Now i am accessing method now.getHours into hours(hours=now.getHours();)
remaining same as above mins=now.getMinutes();secs=now.getSeconds();
Below is for output
document.write(hours + ":" + mins + ":" +secs); copy code from below hear.------------------------------------------------------------------------
<html><head><title>Displaying Times and Dates</title></head>
<body>
<h1>Current Date and Time </h1>
<p>
<script type="text/javascript">
now=new Date();
localtime=now.toString();utctime=now.toGMTString();
document.write("<b>Local time:</b>" + localtime + "<BR>");
document.write("<b>utctime:</b>" + utctime );
document.write("<h1>");
document.write(hours + ":" + mins + ":" +secs);
document.write("</h1>");
</script>
</p>
</body>
</html>
No comments:
Post a Comment