O'Reilly logo

MooTools 1.3 Cookbook by Jay Larry G. Johnston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a time clock that updates per second

We can be sure to keep our users right on time by giving them a running clock that updates every second.

Getting ready

UNIX time, measured in seconds from an arbitrary date in the 1970s, can be difficult to parse out into human-readable time. MooTools makes this much easier in the MooTools MoreDate class. There are also shortcuts for the parameter that can be passed to Date.get():

  • ms/Milliseconds
  • year/FullYear
  • min/Minutes
  • mo/Month
  • sec/Seconds
  • hr/Hours

The seasoned coder will appreciate that all raw JavaScript date elements are available; MooTools only extends the native class.

How to do it...

Making a clock is a task that comes across our desks perennially.

<script type="text/javascript" src="mootools-1.3.0.js"></script> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required