[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

21.1.4 Padding

By default, date pads numeric fields with zeroes, so that, for example, numeric months are always output as two digits. GNU date recognizes the following numeric modifiers between the `%' and the directive.

`-'
(hyphen) do not pad the field; useful if the output is intended for human consumption.
`_'
(underscore) pad the field with spaces; useful if you need a fixed number of characters in the output, but zeroes are too distracting.

These are GNU extensions.

Here is an example illustrating the differences:

 
date +%d/%m -d "Feb 1"
=> 01/02
date +%-d/%-m -d "Feb 1"
=> 1/2
date +%_d/%_m -d "Feb 1"
=>  1/ 2



This document was generated by Jeff Bailey on December, 28 2002 using texi2html