Sunday, May 14, 2017

How can I show my date & time in my site?

By following the code

 

Code Snippet

<html>
<head>
<script language="JavaScript">
function GrabTheDateFunction()
{
   // Get a the current date, then format it for display
   var thisDate = new Date();

   document.write("<p>The current date is: ");
   document.write(thisDate.toDateString());
   document.write("</p>");
}

// other values to use to display date:
// thisDate.toDateString() --> Thu Mar 17 2016
// thisDate.toISOString()  --> 2016-03-17T13:12:18.519Z
// thisDate.toGMTString()  --> Thu, 17 Mar 2016 13:12:18 GMT
// thisDate.toUTCString()  --> Thu, 17 Mar 2016 13:12:18 GMT
// thisDate.toTimeString() --> 09:12:18 GMT-0400 (Eastern Daylight 

Time)

</script>

</head>
<body>
<script language="JavaScript">
    GrabTheDateFunction();
</script>
<h1>The Sample Page</h1>
<p>Let's see this work!</p>
</body>
</html>

No comments:

Post a Comment