Helping ordinary people create extraordinary websites!

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:

Copyright 2004 Bontrager Connection, LLC


 1 Votes

You might also want to check these out:


Leave a Comment on "Basic JavaScript Date and Time Functions "
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS