(JavaScript) Simple Date Functions

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!



javascript date functions date


Back To Top
© 1998 - 2014 psacake.com | My3C's

Version 7.0a | Advertise on this site