JavaScript: The Date Object

13. December 2009 10:17

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>





Comments

7/23/2010 10:12:50 PM #

Dario Naomi

I like your site.

Dario Naomi United States |

7/24/2010 6:21:13 AM #

Enoch Stello

This post is interesting.

Enoch Stello United States |

7/24/2010 6:07:13 PM #

Rosaura Cocopoti

This is a interesting post.

Rosaura Cocopoti United States |

Comments are closed


About the author

 The creators of the Web Design Blog have been creating web designs for over 12 years

Page List