Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Basic JavaScript Date and Time Functions

By Will Bontrager
2004-08-12


Basic JavaScript Date and Time Functions

As the title implies, this tutorial will show you how to get the date and time from the visitor's computer and print them to the web page.

You'll learn two basic techniques:

How to create what's called a date object.

How to extract information from that date object; the hour, minute, month, year, and so forth.

A complete working example of what you'll learn here is near the end of this tutorial.

How To Create What's Called a Date Object

When a date object is created, it is stored in what's called a variable. A variable is simply the name of a place in memory that can contain information. In our example, we'll call that variable "now" because it's a good name for the current date and time.

This is how you create a date object and store it in a variable:

var now = new Date();

The "new Date()" part of the above statement creates the date object. The "var now =" part causes the date object to be stored in the variable named "now".

Tutorial Pages:
» Basic JavaScript Date and Time Functions
» How To Extract Information From that Date Object
» The Date
» The Time
» The Printing
» The Complete Working Example


Copyright 2004 Bontrager Connection, LLC


 | Bookmark
Related Tutorials:
» JavaScript Debugging Techniques with Firebug
» Striped Tables Using JavaScript
» Opening PDFs in a New Window with JavaScript
» Essential Javascript -- A Javascript Tutorial
» Submit Forms Conditionally using JavaScript
» How to Setup a Randomising Function