Home arrow JavaScript arrow Page 3 - Javascript Objects: More Date Methods
JAVASCRIPT

Javascript Objects: More Date Methods


We previously left off discussing a smattering of JavaScript Date Objects. In this tutorial we will continue the discussion, picking up with the GetFullYear() Method. There are a ton of Date methods, so let's get started.

Author Info:
By: James Payne
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
February 11, 2008
TABLE OF CONTENTS:
  1. · Javascript Objects: More Date Methods
  2. · The GetHours() Method
  3. · Putting the Three Together
  4. · The GetTime() Method
  5. · The GetUTDate, Month, FullYear() Methods

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Javascript Objects: More Date Methods - Putting the Three Together
(Page 3 of 5 )

You can put the hour, minutes, and seconds together of course (as well as the other units of time). Here is a quick program to demonstrate how to do so:


<html>

<body>

<script type="text/javascript">

var time = new Date()

document.write("The time is currently: ")

document.write(time.getHours())

document.write(":")

document.write(time.getMinutes())

document.write(":")

document.write(time.getSeconds())

</script>

</body>

</html>

This would result in the print out:

  The time is currently: 18:23:08

Of course we could always get really anal and add milliseconds to that as well:


<html>

<body>

<script type="text/javascript">

var time = new Date()

document.write("The Present time is: ")

document.write(time.getHours())

document.write(".")

document.write(time.getMinutes())

document.write(".")

document.write(time.getSeconds())

document.write(".")

document.write(time.getMilliseconds())

</script>

</body>

</html>

And the fantastic result is:

  The Present time is: 14.12.34.750


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials