Optional ShowDate Function (JavaScript) Simple Date Functions
CSGNetwork FREE Source Code, Javascript Source, and Code Snippets!
CSGNetwork Custom Search
     Bookmark and Share
Top Free Apps

Right click this window and select "view source" in order to copy the source for this script.

Optional ShowDate Function

The are many things you can do with dates using Javascript. The examples below illustrate several types of date displays;

How it Works

The script contains the basic Date values (eg. month, weekday, etc) necessary to perform almost any Date calculations or display any date format. It also contains several pre-written functions that create some useful date displays. Here's a list of the available date display functions;

  1. showGreeting() - "Good Morning", "Good Afternoon" or "Good Evening"
  2. showTime(type) - "c" civilian time, "m" military time
  3. showDate(format) - various date/time formats
  4. showCalendar() - a calendar showing todays date
  5. showTimer() - elapsed time
  6. showDays(when) - number of days untill some event

Using the JavaScript

To implement this script, simply;

  1. copy the HTML below into a new page.
  2. add your scripts at the appropriate locations on the page. It should look something like this;

    <script language="JavaScript"><!--showDate("dddd, mm dd, yyyy");// --></script>
The Result

You entered this page at   () on

Christmas is days away!

Your elapsed time on this page is being displayed on the status line..

Optional ShowDate Function

This group of routines demonstrates the capabilities of our optional ShowDate function; call it where ever it is needed.
View the source...

Bookmark and Share
Registered® Trademark™ and Copyrightę 1973 - CSG, Computer Support Group, Inc. and CSGNetwork.Com All Rights Reserved