BrainDump
  Home arrow BrainDump arrow Page 4 - VBScript: Final Date Functions
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 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? 
BRAINDUMP

VBScript: Final Date Functions
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-04-01

    Table of Contents:
  • VBScript: Final Date Functions
  • Here and Now
  • Time is Always Against Us
  • Timer...It Has Its Eye On You
  • The TimeValue() 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
     
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    VBScript: Final Date Functions - Timer...It Has Its Eye On You
    (Page 4 of 5 )

    The Timer() function returns the amount of seconds since 12:00 am (midnight). You can also perform calculations based on the Timer() function, such as seeing how many hours or minutes have passed. Here it is in code:


    <html>

    <body>

    <script type="text/vbscript">

    document.write("The amount of seconds since 12 am: ") & (Timer) & "<br />"

    document.write("The amount of minutes since 12 am: ") & (Timer/60) & "<br />"

    document.write("The amount of hours since 12 am: ") & (Timer/3600) & "<br />"

    </script>

    </body>

    </html>

    Which gives us the result:

      The amount of seconds since 12 am: 40718.42
      The amount of minutes since 12 am: 678.6404
      The amount of hours since 12 am: 11.31067

    Cereal Time

    I just scarfed down a box of Apple Jacks, probably the best cereal on the planet. I don't know why Cookie Crisp doesn't have the foresight to make those mini boxes of cereal. I mean they would have total market domination if they did, just from me alone.

    The TimeSerial() function returns the time for an hour, minute, and second that you specify. It is comprised of three sections, separated by commas. The first is for the hour, the second is for minutes, and the third is for seconds. You can also perform math on these sections, as you will see below:


    <html>

    <body>

    <script type="text/vbscript">

    document.write(TimeSerial(10,8,32)) & "<br />"

    document.write(TimeSerial(22,18,59)) & "<br />"

    document.write(TimeSerial(0,0,0)) & "<br />"

    document.write(TimeSerial(12,0,0)) & "<br />"

    document.write(TimeSerial(22-14,18+3,12*3)) & "<br />"

    </script>

    </body>

    </html>

    And as always, our result:

      10:08:32 AM
      10:18:59 PM
      12:00:00 AM
      12:00:00 PM
      8:21:36 AM

    Note that this works off of military time, so 12, 0, 0 equals 12:00:00 PM and 0,0,0 equals 12:00:00 AM.

    More BrainDump Articles
    More By James Payne


       · Thanks for stopping by to read another article. In this episode we discuss the last...
     

    BRAINDUMP ARTICLES

    - Handling Multiple Contracts with Indigo
    - Cleaning Out Your Data in XP
    - Multiple Service Contracts and Indigo
    - Cleaning Out Your Programs in XP
    - Handling Metadata with Indigo
    - Building Blocks for a WCF Service Web Site
    - Help! I Need Some Remote Assistance
    - Using Service Templates with Indigo
    - Windows XP Tips for Task Manager
    - Generating Clients and Services with Indigo
    - Vista SP1, A Review
    - Services and the WCF
    - VBScript: Final Date Functions
    - Creating Services with the WCF
    - The Resource View of the MFC




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