mktime -- A command to manipulate time and date values

Doing time and date calculations in shell scripts has never been easy. Often people resort to bad hacks like changing TZ, or doing naive manipulations that don't work quite right around daylight savings time changes and so on. GNU date's --date flag can do simple manipulations, but the way it does is not well documented, and is an over-loading of an existing command.

The mktime command is simple way to handle most of these problems, based on the mktime() call in Standard C. The C mktime() allows you to partially fill in a date structure (even allowing dates and times not normally considered valid) and then fixes the structure up to reflect the intended date and time. The command version is similar, except that instead of filling in a structure, values are provided on the command line, and the resulting date is printed on the standard output. See the manual page for details.

In the somewhat long lost spirit of the UNIX shell (back when "cat" had no options), it was intended to be a simple tool with a fairly focused objective. It does NOT, for instance, try to parse every imaginable natural language date format as GNU date's --date does, though such a function is undoubtedly useful. But mktime just does date calculations.

See the INSTALL file for build and porting instructions. It should build easily on most UNIX platforms; any porting efforts should be minor (knock on wood).

I am very interested in comments about how useful (or not) people find this tool, missing features, bad existing features, etc. In my fantasies (no, not THOSE ones), something like mktime (but not necessarily mktime; I'm not a megalomaniac) ends up in the Single UNIX Specification, and shell scripts everywhere will be able to use it. With that in mind, this package is in the public domain. I would appreciate bug fixes, enhancements, etc. though.

I'll try to keep information about current version, bug fixes, and so on at but I make no promises. For e-mail, download the real distribution and check the README there.

John R MacMillan