There are a number of methods for obtaining current date and time info.
Output:
Code:
<script type="text/javascript"> //<![CDATA[ document.write("Displaying the Date object shows the current date and time: " + Date() + "<br /><br />"); var d = new Date(); document.write("The <b>getTime()</b> method shows the number of milliseconds since 1/1/1970: " + d.getTime() + "<br /><br />"); document.write("The <b>getDate()</b> method shows the current day of the month: " + d.getDate() + "<br /><br />"); document.write("The <b>getMonth()</b> method shows the current month minus one (starts counting at zero): " + d.getMonth() + "<br /><br />"); document.write("The <b>getFullYear()</b> method shows the current year: " + d.getFullYear() + "<br /><br />"); document.write("The <b>getHours()</b> method shows the hours portion of the current time: " + d.getHours() + "<br /><br />"); document.write("The <b>getMinutes()</b> method shows the minutes portion of the current time: " + d.getMinutes() + "<br /><br />"); document.write("The <b>getSeconds()</b> method shows the seconds portion of the current time: " + d.getSeconds() + "<br /><br />"); document.write("The <b>getMilliseconds()</b> method shows the milliseconds portion of the current time: " + d.getMilliseconds() + "<br /><br />"); document.write("The <b>getMilliseconds()</b> method shows the milliseconds portion of the current time: " + d.getMilliseconds() + "<br /><br />"); document.write("The <b>toGMTString()</b> method converts the current date-time, Greenwich Mean Time (GMT), to a string and returns the result. The toUTCString() method should be used instead: " + d.toGMTString() + "<br /><br />"); document.write("The <b>toUTCString()</b> method converts the current date-time, Greenwich Mean Time (GMT), to a string and returns the result: " + d.toUTCString() + "<br /><br />"); document.write("The <b>toLocaleString()</b> method converts the current date-time, local time, to a string and returns the result: " + d.toLocaleString() + "<br /><br />"); document.write("The <b>toLocaleTimeString()</b> method converts the current local time to a string and returns the result: " + d.toLocaleTimeString() + "<br /><br />"); document.write("The <b>UTC()</b> method: Based on a comma delimited string, the number of milliseconds after midnight January 1, 1970 GMT is returned. The syntax of the string is 'year, month, day [, hrs] [, min] [, sec]'. An example is '2000, 9, 29, 5, 43, 0' for Sept 29, 2000 at 5:43:0. The string is considered to be GMT. The hours, minutes, and seconds are optional. " + Date.UTC(2000, 9, 29, 5, 43, 0) + "<br /><br />"); //]]> </script>