JavaScript
  Home arrow JavaScript arrow Page 3 - JavaScript Date Objects: Universal Coordin...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

JavaScript Date Objects: Universal Coordinated Time
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2008-02-22

    Table of Contents:
  • JavaScript Date Objects: Universal Coordinated Time
  • The GetUTCHour, Minute, Second, and Milliseconds() Function
  • Introducing One of the Most Asinine Functions Ever
  • Using the UTC() Function

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    JavaScript Date Objects: Universal Coordinated Time - Introducing One of the Most Asinine Functions Ever


    (Page 3 of 4 )

    If you love the date 01/01/1970 -- and let's face it, who doesn't? -- and feel the insane need to know how many milliseconds have passed since that vainglorious date, JavaScript has a function that will knock your socks off, slap your momma, and make the cows quit their European traveling and come back home.

    The parse() function people, in all its momentous beauty:


    <html>

    <body>

    <script type="text/javascript">

    var d = Date.parse("Dec 15 2007");

    document.write("Behold! ")

    document.write(d);

    document.write(" milliseconds have passed between Jan 01, 1970-Dec 15 2007!")

    </script>

    </body>

    </html>

    The result:

      Behold! 1197694800000 milliseconds have passed between Jan 01, 1970-Dec 15 2007!

    Here is another example, where we make the parse() function a little more useful by tallying up the amount of minutes, hours, days, and years between 01/01/1970 and 12/15/2007:


    <html>

    <body>

    <script type="text/javascript">

    var minutes = 1000 * 60;

    var hours = minutes * 60;

    var days = hours * 24;

    var years = days * 365;

    var toe = Date.parse("Dec 15, 2007");

    document.write("Here is a list of minutes, hours, days, and years");

    document.write("<br />")

    document.write("That have passed between 01/01/1970 and 12/15/1007");

    document.write("<br />")

    document.write("<br />")

    document.write("Minutes that have passed: " + toe/minutes);

    document.write("<br />")

    document.write("Hours that have passed: " + toe/hours);

    document.write("<br />")

    document.write("Days that have passed: " + toe/days);

    document.write("<br />")

    document.write("Years that have passed: " + toe/years);

    </script>

    </body>

    </html>

    And once more, the result:

      Here is a list of minutes, hours, days, and years
      That have passed between 01/01/1970 and 12/15/1007

      Minutes that have passed: 19961580
      Hours that have passed: 332693
      Days that have passed: 13862.208333333334
      Years that have passed: 37.97865296803653

    More JavaScript Articles
    More By James Payne


       · Thanks for dropping by to check out my article discussing more of the Javascript...
     

    JAVASCRIPT ARTICLES

    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget
    - Ajax Hack for Entering Information Without R...
    - EXT JS 2.1 Overview
    - Using the Style Object for Zebra Tables with...
    - Binary Searching
    - An Improved Approach to Building Zebra Tables
    - Assigning Background Colors Dynamically to Z...
    - Building Zebra Tables with CSS and JavaScript
    - JavaScript: Array Objects
    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...
    - Bulleted Menu of Links
    - Creating Click Loggers and Basic Markers wit...
    - Adding Pan Controls to Yahoo! Maps







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway