JavaScript: The Date Object
Another object built into JavaScript is the Date object. You can use this object to show or set the current date and time. It can also be used to do comparisons between different dates and times. To use this object you must first create a new Date object.
<script type= “text/javascript”>
var makeDate= new Date(); /* Declares a new Date object with default settings. The default
function show()
{
var win=window.open("","details");
format is displayed as Day Month Date HH:MM:SS Time Zone Year*/
win.document.write("The Date Getters");
win.document.write("<br />");
win.document.write("Date=" + makeDate.Date());
win.document.write("<br />");
win.document.write("Day=" + makeDate.getDay());
win.document.write("<br />");
win.document.write("Month=" + makeDate.getMonth());
win.document.write("The Time Getters");
win.document.write("<br />");
win.document.write("Hour=" + makeDate.getHour(););
win.document.write("<br />");
win.document.write("Minutes=" + makeDate.getMinutes());
win.document.write("<br />");
win.document.write("Seconds=" + makeDate.getSeconds());
win.document.write("<br />");
}
// --></script>
<input onclick="show()" type="button" value="Show date/time details" /></p>